{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据导入"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "导入原始数据："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "df_data = pd.read_csv(\"data.csv\")\n",
    "df_label = pd.read_csv(\"label.csv\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "看一眼数据："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>AGE</th>\n",
       "      <th>AST</th>\n",
       "      <th>AST_PCT</th>\n",
       "      <th>AST_PCT_RANK</th>\n",
       "      <th>AST_RANK</th>\n",
       "      <th>AST_RATIO</th>\n",
       "      <th>AST_RATIO_RANK</th>\n",
       "      <th>AST_TO</th>\n",
       "      <th>AST_TO_RANK</th>\n",
       "      <th>BLK</th>\n",
       "      <th>...</th>\n",
       "      <th>TOV</th>\n",
       "      <th>TOV_RANK</th>\n",
       "      <th>TS_PCT</th>\n",
       "      <th>TS_PCT_RANK</th>\n",
       "      <th>USG_PCT</th>\n",
       "      <th>USG_PCT_RANK</th>\n",
       "      <th>W</th>\n",
       "      <th>W_PCT</th>\n",
       "      <th>W_PCT_RANK</th>\n",
       "      <th>W_RANK</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>30.0</td>\n",
       "      <td>2.4</td>\n",
       "      <td>0.127</td>\n",
       "      <td>164</td>\n",
       "      <td>103</td>\n",
       "      <td>10.7</td>\n",
       "      <td>254</td>\n",
       "      <td>1.05</td>\n",
       "      <td>203</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>2.3</td>\n",
       "      <td>63</td>\n",
       "      <td>0.544</td>\n",
       "      <td>90</td>\n",
       "      <td>0.262</td>\n",
       "      <td>27</td>\n",
       "      <td>16</td>\n",
       "      <td>0.571</td>\n",
       "      <td>145</td>\n",
       "      <td>61</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>26.0</td>\n",
       "      <td>4.7</td>\n",
       "      <td>0.234</td>\n",
       "      <td>65</td>\n",
       "      <td>32</td>\n",
       "      <td>14.0</td>\n",
       "      <td>187</td>\n",
       "      <td>1.46</td>\n",
       "      <td>128</td>\n",
       "      <td>0.3</td>\n",
       "      <td>...</td>\n",
       "      <td>3.2</td>\n",
       "      <td>13</td>\n",
       "      <td>0.489</td>\n",
       "      <td>232</td>\n",
       "      <td>0.319</td>\n",
       "      <td>2</td>\n",
       "      <td>18</td>\n",
       "      <td>0.692</td>\n",
       "      <td>47</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>34.0</td>\n",
       "      <td>2.6</td>\n",
       "      <td>0.127</td>\n",
       "      <td>165</td>\n",
       "      <td>93</td>\n",
       "      <td>14.6</td>\n",
       "      <td>170</td>\n",
       "      <td>1.23</td>\n",
       "      <td>175</td>\n",
       "      <td>0.3</td>\n",
       "      <td>...</td>\n",
       "      <td>2.1</td>\n",
       "      <td>71</td>\n",
       "      <td>0.543</td>\n",
       "      <td>92</td>\n",
       "      <td>0.187</td>\n",
       "      <td>187</td>\n",
       "      <td>15</td>\n",
       "      <td>0.517</td>\n",
       "      <td>195</td>\n",
       "      <td>73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>32.0</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.067</td>\n",
       "      <td>285</td>\n",
       "      <td>164</td>\n",
       "      <td>8.6</td>\n",
       "      <td>303</td>\n",
       "      <td>0.78</td>\n",
       "      <td>255</td>\n",
       "      <td>2.2</td>\n",
       "      <td>...</td>\n",
       "      <td>1.9</td>\n",
       "      <td>94</td>\n",
       "      <td>0.490</td>\n",
       "      <td>229</td>\n",
       "      <td>0.190</td>\n",
       "      <td>170</td>\n",
       "      <td>14</td>\n",
       "      <td>0.519</td>\n",
       "      <td>189</td>\n",
       "      <td>104</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>26.0</td>\n",
       "      <td>1.9</td>\n",
       "      <td>0.099</td>\n",
       "      <td>212</td>\n",
       "      <td>131</td>\n",
       "      <td>8.0</td>\n",
       "      <td>310</td>\n",
       "      <td>0.70</td>\n",
       "      <td>270</td>\n",
       "      <td>1.2</td>\n",
       "      <td>...</td>\n",
       "      <td>2.6</td>\n",
       "      <td>41</td>\n",
       "      <td>0.550</td>\n",
       "      <td>78</td>\n",
       "      <td>0.275</td>\n",
       "      <td>18</td>\n",
       "      <td>14</td>\n",
       "      <td>0.519</td>\n",
       "      <td>189</td>\n",
       "      <td>104</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 173 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    AGE  AST  AST_PCT  AST_PCT_RANK  AST_RANK  AST_RATIO  AST_RATIO_RANK  \\\n",
       "0  30.0  2.4    0.127           164       103       10.7             254   \n",
       "1  26.0  4.7    0.234            65        32       14.0             187   \n",
       "2  34.0  2.6    0.127           165        93       14.6             170   \n",
       "3  32.0  1.5    0.067           285       164        8.6             303   \n",
       "4  26.0  1.9    0.099           212       131        8.0             310   \n",
       "\n",
       "   AST_TO  AST_TO_RANK  BLK   ...    TOV  TOV_RANK  TS_PCT  TS_PCT_RANK  \\\n",
       "0    1.05          203  0.0   ...    2.3        63   0.544           90   \n",
       "1    1.46          128  0.3   ...    3.2        13   0.489          232   \n",
       "2    1.23          175  0.3   ...    2.1        71   0.543           92   \n",
       "3    0.78          255  2.2   ...    1.9        94   0.490          229   \n",
       "4    0.70          270  1.2   ...    2.6        41   0.550           78   \n",
       "\n",
       "   USG_PCT  USG_PCT_RANK   W  W_PCT  W_PCT_RANK  W_RANK  \n",
       "0    0.262            27  16  0.571         145      61  \n",
       "1    0.319             2  18  0.692          47      31  \n",
       "2    0.187           187  15  0.517         195      73  \n",
       "3    0.190           170  14  0.519         189     104  \n",
       "4    0.275            18  14  0.519         189     104  \n",
       "\n",
       "[5 rows x 173 columns]"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PLAYER_ID</th>\n",
       "      <th>TEAM_ID</th>\n",
       "      <th>PLAYER_NAME</th>\n",
       "      <th>ALL_STAR</th>\n",
       "      <th>YEAR</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>275</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Allan Houston</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>947</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Allen Iverson</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>193</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Anthony Mason</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>213</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Antonio Davis</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>686</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Antonio McDyess</td>\n",
       "      <td>1.0</td>\n",
       "      <td>2000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   PLAYER_ID       TEAM_ID      PLAYER_NAME  ALL_STAR  YEAR\n",
       "0        275  1.610613e+09    Allan Houston       1.0  2000\n",
       "1        947  1.610613e+09    Allen Iverson       1.0  2000\n",
       "2        193  1.610613e+09    Anthony Mason       1.0  2000\n",
       "3        213  1.610613e+09    Antonio Davis       1.0  2000\n",
       "4        686  1.610613e+09  Antonio McDyess       1.0  2000"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_label.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "其中，`YEAR=2000`表示当前为2000-01赛季。`ALL_STAR=1`表示当季是全明星，`ALL_STAR=0`表示不是。\n",
    "\n",
    "为了方便，可以对数据进行归一化，得到零均值单位方差的新数据："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "df_data_norm = (df_data - df_data.mean()) / (df_data.std() +np.spacing(0))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "我们将2000-2016年的已知数据作为训练集，而将17年的数据作为测试集："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "df_data_train = df_data.loc[df_label.YEAR < 2017]\n",
    "df_data_test = df_data.loc[df_label.YEAR == 2017]\n",
    "\n",
    "df_data_norm_train = df_data_norm.loc[df_label.YEAR < 2017]\n",
    "df_data_norm_test = df_data_norm.loc[df_label.YEAR == 2017]\n",
    "\n",
    "df_label_test = df_label.loc[df_label.YEAR == 2017]\n",
    "df_label_train = df_label.loc[df_label.YEAR < 2017]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 统计结果"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "00-01赛季到16-17赛季，全明星总人次："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "396.0"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum(df_label_train.ALL_STAR)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "有统计数据的球员总人次："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6850"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(df_label_train)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "占比示意图："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWQAAADuCAYAAAAOR30qAAAABHNCSVQICAgIfAhkiAAAA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o6HvNlvOI2VMhSx5k12l8W/AEcCXgH52E3VKM/AY\n2RIOfXeJ5TxSQVTIUhCOF1QDe2c/9gD2BD4P9LWZ62M2AP8kvig3H3geWBj6bpPVVFKxVMhSNI4X\nGGAUGwt6D2AsMJzCFvUG4G3gLeBFNpbvotB32wv4viI5USFLImTno4cAQ7O/bvr5YOIbVSIgk/31\n45+3A+8DKzf5eBd4O/Td1cX8WkQ6S4UsIpIQuj1WRCQhVMgiIgmhQhYRSQgVsohIQqiQRUQSQoUs\nIpIQKmQRkYRQIYuIJIQKWUQkIVTIIiIJoUIWEUkIFbKISEKokEVEEkKFLCKSECpkEZGEUCGLiCSE\nCllEJCFUyCIiCaFCFhFJCBWyiEhC/D+4jI8YqwbNtQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x109e1efd0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from matplotlib import pyplot as plt\n",
    "\n",
    "%matplotlib inline\n",
    "\n",
    "plt.pie([len(df_label_train) - sum(df_label_train.ALL_STAR), sum(df_label_train.ALL_STAR)], \n",
    "        explode=(0, 0.1), labels=[\"others\", \"all-star\"], autopct='%1.1f%%',)\n",
    "plt.axis(\"equal\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "球员总数："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1475"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(set(df_label_train.PLAYER_ID))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "全明星球员数："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "118"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(set(df_label_train.PLAYER_ID.loc[df_label_train.ALL_STAR==1]))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "占比："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWQAAADuCAYAAAAOR30qAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHTlJREFUeJzt3XmUFNWhx/HvnWFggIFBxA1ES8E1RlCJaGIiMW6xnksU\n9WncQtSnxrjkuZRxKxOjpcYYl2hc8uL2Ek1wO7FMDPrcUVBU4hJ3Ky5gRISGYVhmue+PalkUcHqm\nu2919+9zzhxh7J7+DYf+cefWvbeMtRYREXGvznUAERFJqZBFRDJChSwikhEqZBGRjFAhi4hkhApZ\nRCQjVMgiIhmhQhYRyQgVsohIRqiQRUQyQoUsIpIRKmQRkYxQIYuIZIQKWUQkI1TIIiIZoUIWEckI\nFbKISEaokEVEMkKFLCKSEb1cBxD5jBfEfYG1gYGr+RgAdAALV/OxAPgIeD+J/Jbyfhci3Wd0k1Mp\nJy+IG4CNgU2BTT7332GAKfJL5oD3gXeBt4E3gbeA15LIf6/IryXSIypkKRkviPsA2wI7Al8HRgMe\nUO8w1vI+AqYAz+Q/nk0if4HbSFLLVMhSNF4QN5IW77fzH2OAPk5DFaYDeJllBf1wEvnvu40ktUSF\nLD3iBfHawHhgf2AnKquAu2IacA9wTxL5r7oOI9VNhSwF84J4CGkBHwzsTHamIErtDfLlDExNIl9v\nHikqFbJ0iRfEa5CW8EHALmiFzgzgbuD6JPJfdh1GqoMKWVbLC+KxwKmkZdzgOE5WPQ78Brg7ifx2\n12GkcqmQ5Qu8IK4nLeBTSVdISNfMAG4Abkgif6brMFJ5VMiylBfEA4FjgB8DGzqOU8naSOeZr0ki\n/wnXYaRyqJAFL4jXB04DJpDuhJPieRw4N4n8x10HkexTIdew/Ij4LOAUoNFxn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wA3AGNcZ5EvmA9cCPw6iXzd6LbGqZBrhBfEdcCJpG/+AY7jSHpD21uAs5LI\n/8h1GMkGFXKN8YJ4GHA5cBBgHMepVVOAk/J3GxdZSoVco7wg/ipwPukpcirm8pgJnAncnkS+3njy\nBSrkGucF8SggBPZzHKWafQD8CrghifwFrsNIdqmQBVh64S8E9nEcpZq8ClwK/CGJ/DbXYST7VMiy\nAi+ItwPOJi1mLZXrnsmk51b/RVMTUggVsqyUF8TDgf8CjgbWcRynEnSS3iX8kiTyn3QdRiqTCllW\nywviBtKzlycAu6Ht9p/3NnAzcEsS+e87ziIVToUsXeYF8frAEcBRwCZu0zg1G7gbuB14QtMSUiwq\nZOmW/MlyPvAfwNeBXm4Tldxc0jt/3wFM0kU6KQUVsvSYF8SDgD1JC/q7wJpuExXFQuAp4OH8x/NJ\n5He4jSTVToUsRZXfor0DsAuwXf6jEk6cayc99vKzAn46ifzFbiNJrVEhS8l5Qbw2sC3LCno7YAOH\nkWYAr5CuE34l//GSbhwqrqmQxQkviIcAI4Fhy32s/7nf9+3Gl86RXnT77OMT4GPgNfIlnET+3J7m\nFykFFbJklhfEa5CeTNcI9Mn/t4EVz96wpBfcZgOzdbC7VDIVsohIRmiRv4hIRqiQRUQyQoUsIpIR\nKmQRkYxQIYuIZIQKWUQkI1TIIiIZoUIWEckIFbKISEaokEVEMkKFLCKSESpkEZGMUCGLiGSECllE\nJCNUyCIiGaFCFhHJCBWyiEhGqJBFRDJChSwikhH/D0kiyTkh38a+AAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x10a411fd0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.pie([len(set(df_label_train.PLAYER_ID)) - len(set(df_label_train.PLAYER_ID.loc[df_label_train.ALL_STAR==1])),\n",
    "         len(set(df_label_train.PLAYER_ID.loc[df_label_train.ALL_STAR==1]))], \n",
    "        explode=(0, 0.1), labels=[\"others\", \"all-star\"], autopct='%1.1f%%',)\n",
    "plt.axis(\"equal\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "参加全明星次数："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('Tim Duncan', 13),\n",
       " ('LeBron James', 13),\n",
       " ('Kobe Bryant', 13),\n",
       " ('Dirk Nowitzki', 13),\n",
       " ('Dwyane Wade', 11),\n",
       " ('Kevin Garnett', 11),\n",
       " ('Carmelo Anthony', 10),\n",
       " ('Chris Bosh', 9),\n",
       " ('Ray Allen', 9),\n",
       " ('Paul Pierce', 9)]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from collections import Counter\n",
    "\n",
    "allstar_times = Counter(df_label_train.PLAYER_NAME.loc[df_label_train.ALL_STAR==1])\n",
    "\n",
    "allstar_times.most_common(10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## SVM"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn import svm"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "svm训练及预测，这里需要用归一化的数据："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "svm_predict = svm.SVC().fit(df_data_norm_train, \n",
    "                            df_label_train.ALL_STAR).predict(df_data_norm_test)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "选中了21位："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "21.0"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum(svm_predict)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "分别是："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PLAYER_ID</th>\n",
       "      <th>TEAM_ID</th>\n",
       "      <th>PLAYER_NAME</th>\n",
       "      <th>ALL_STAR</th>\n",
       "      <th>YEAR</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6873</th>\n",
       "      <td>203076</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Anthony Davis</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6891</th>\n",
       "      <td>203078</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Bradley Beal</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6913</th>\n",
       "      <td>101108</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Chris Paul</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6926</th>\n",
       "      <td>203081</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Damian Lillard</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6947</th>\n",
       "      <td>201942</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>DeMar DeRozan</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6948</th>\n",
       "      <td>202326</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>DeMarcus Cousins</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7001</th>\n",
       "      <td>203507</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Giannis Antetokounmpo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7040</th>\n",
       "      <td>201935</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>James Harden</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7061</th>\n",
       "      <td>202710</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Jimmy Butler</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7069</th>\n",
       "      <td>203954</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Joel Embiid</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7074</th>\n",
       "      <td>202322</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>John Wall</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7103</th>\n",
       "      <td>1626157</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Karl-Anthony Towns</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7112</th>\n",
       "      <td>201142</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kevin Durant</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7113</th>\n",
       "      <td>201567</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kevin Love</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7117</th>\n",
       "      <td>202691</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Klay Thompson</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7121</th>\n",
       "      <td>204001</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kristaps Porzingis</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7129</th>\n",
       "      <td>202681</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kyrie Irving</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7130</th>\n",
       "      <td>200746</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>LaMarcus Aldridge</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7136</th>\n",
       "      <td>2544</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>LeBron James</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7257</th>\n",
       "      <td>201939</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Stephen Curry</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7303</th>\n",
       "      <td>203506</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Victor Oladipo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      PLAYER_ID       TEAM_ID            PLAYER_NAME  ALL_STAR  YEAR\n",
       "6873     203076  1.610613e+09          Anthony Davis       0.0  2017\n",
       "6891     203078  1.610613e+09           Bradley Beal       0.0  2017\n",
       "6913     101108  1.610613e+09             Chris Paul       0.0  2017\n",
       "6926     203081  1.610613e+09         Damian Lillard       0.0  2017\n",
       "6947     201942  1.610613e+09          DeMar DeRozan       0.0  2017\n",
       "6948     202326  1.610613e+09       DeMarcus Cousins       0.0  2017\n",
       "7001     203507  1.610613e+09  Giannis Antetokounmpo       0.0  2017\n",
       "7040     201935  1.610613e+09           James Harden       0.0  2017\n",
       "7061     202710  1.610613e+09           Jimmy Butler       0.0  2017\n",
       "7069     203954  1.610613e+09            Joel Embiid       0.0  2017\n",
       "7074     202322  1.610613e+09              John Wall       0.0  2017\n",
       "7103    1626157  1.610613e+09     Karl-Anthony Towns       0.0  2017\n",
       "7112     201142  1.610613e+09           Kevin Durant       0.0  2017\n",
       "7113     201567  1.610613e+09             Kevin Love       0.0  2017\n",
       "7117     202691  1.610613e+09          Klay Thompson       0.0  2017\n",
       "7121     204001  1.610613e+09     Kristaps Porzingis       0.0  2017\n",
       "7129     202681  1.610613e+09           Kyrie Irving       0.0  2017\n",
       "7130     200746  1.610613e+09      LaMarcus Aldridge       0.0  2017\n",
       "7136       2544  1.610613e+09           LeBron James       0.0  2017\n",
       "7257     201939  1.610613e+09          Stephen Curry       0.0  2017\n",
       "7303     203506  1.610613e+09         Victor Oladipo       0.0  2017"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_label_test.iloc[svm_predict == 1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### KNN"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn import neighbors"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "预测，这里需要用归一化的数据："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "knn_predict = neighbors.KNeighborsClassifier(n_neighbors=1).fit(df_data_norm_train, \n",
    "                                                                df_label_train.ALL_STAR).predict(df_data_norm_test)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "选中了："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "26.0"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum(knn_predict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PLAYER_ID</th>\n",
       "      <th>TEAM_ID</th>\n",
       "      <th>PLAYER_NAME</th>\n",
       "      <th>ALL_STAR</th>\n",
       "      <th>YEAR</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6885</th>\n",
       "      <td>201933</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Blake Griffin</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6921</th>\n",
       "      <td>1626156</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>D'Angelo Russell</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6947</th>\n",
       "      <td>201942</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>DeMar DeRozan</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6948</th>\n",
       "      <td>202326</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>DeMarcus Cousins</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6953</th>\n",
       "      <td>203471</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Dennis Schroder</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6961</th>\n",
       "      <td>1626164</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Devin Booker</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6973</th>\n",
       "      <td>203110</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Draymond Green</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7001</th>\n",
       "      <td>203507</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Giannis Antetokounmpo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7040</th>\n",
       "      <td>201935</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>James Harden</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7061</th>\n",
       "      <td>202710</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Jimmy Butler</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7074</th>\n",
       "      <td>202322</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>John Wall</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7108</th>\n",
       "      <td>202689</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kemba Walker</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7112</th>\n",
       "      <td>201142</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kevin Durant</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7113</th>\n",
       "      <td>201567</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kevin Love</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7116</th>\n",
       "      <td>203114</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Khris Middleton</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7117</th>\n",
       "      <td>202691</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Klay Thompson</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7126</th>\n",
       "      <td>200768</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kyle Lowry</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7129</th>\n",
       "      <td>202681</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kyrie Irving</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7136</th>\n",
       "      <td>2544</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>LeBron James</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7154</th>\n",
       "      <td>201188</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Marc Gasol</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7198</th>\n",
       "      <td>203999</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Nikola Jokic</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7216</th>\n",
       "      <td>202331</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Paul George</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7217</th>\n",
       "      <td>200794</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Paul Millsap</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7240</th>\n",
       "      <td>201566</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Russell Westbrook</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7257</th>\n",
       "      <td>201939</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Stephen Curry</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7303</th>\n",
       "      <td>203506</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Victor Oladipo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      PLAYER_ID       TEAM_ID            PLAYER_NAME  ALL_STAR  YEAR\n",
       "6885     201933  1.610613e+09          Blake Griffin       0.0  2017\n",
       "6921    1626156  1.610613e+09       D'Angelo Russell       0.0  2017\n",
       "6947     201942  1.610613e+09          DeMar DeRozan       0.0  2017\n",
       "6948     202326  1.610613e+09       DeMarcus Cousins       0.0  2017\n",
       "6953     203471  1.610613e+09        Dennis Schroder       0.0  2017\n",
       "6961    1626164  1.610613e+09           Devin Booker       0.0  2017\n",
       "6973     203110  1.610613e+09         Draymond Green       0.0  2017\n",
       "7001     203507  1.610613e+09  Giannis Antetokounmpo       0.0  2017\n",
       "7040     201935  1.610613e+09           James Harden       0.0  2017\n",
       "7061     202710  1.610613e+09           Jimmy Butler       0.0  2017\n",
       "7074     202322  1.610613e+09              John Wall       0.0  2017\n",
       "7108     202689  1.610613e+09           Kemba Walker       0.0  2017\n",
       "7112     201142  1.610613e+09           Kevin Durant       0.0  2017\n",
       "7113     201567  1.610613e+09             Kevin Love       0.0  2017\n",
       "7116     203114  1.610613e+09        Khris Middleton       0.0  2017\n",
       "7117     202691  1.610613e+09          Klay Thompson       0.0  2017\n",
       "7126     200768  1.610613e+09             Kyle Lowry       0.0  2017\n",
       "7129     202681  1.610613e+09           Kyrie Irving       0.0  2017\n",
       "7136       2544  1.610613e+09           LeBron James       0.0  2017\n",
       "7154     201188  1.610613e+09             Marc Gasol       0.0  2017\n",
       "7198     203999  1.610613e+09           Nikola Jokic       0.0  2017\n",
       "7216     202331  1.610613e+09            Paul George       0.0  2017\n",
       "7217     200794  1.610613e+09           Paul Millsap       0.0  2017\n",
       "7240     201566  1.610613e+09      Russell Westbrook       0.0  2017\n",
       "7257     201939  1.610613e+09          Stephen Curry       0.0  2017\n",
       "7303     203506  1.610613e+09         Victor Oladipo       0.0  2017"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_label_test.iloc[knn_predict == 1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "如果使用原始特征："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "knn_predict = neighbors.KNeighborsClassifier(n_neighbors=1).fit(df_data_train, \n",
    "                                                                df_label_train.ALL_STAR).predict(df_data_test)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "选中了："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "26.0"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum(knn_predict)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "选中的人会有所变化："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PLAYER_ID</th>\n",
       "      <th>TEAM_ID</th>\n",
       "      <th>PLAYER_NAME</th>\n",
       "      <th>ALL_STAR</th>\n",
       "      <th>YEAR</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6885</th>\n",
       "      <td>201933</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Blake Griffin</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6891</th>\n",
       "      <td>203078</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Bradley Beal</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6931</th>\n",
       "      <td>201568</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Danilo Gallinari</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6947</th>\n",
       "      <td>201942</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>DeMar DeRozan</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6948</th>\n",
       "      <td>202326</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>DeMarcus Cousins</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6961</th>\n",
       "      <td>1626164</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Devin Booker</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6973</th>\n",
       "      <td>203110</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Draymond Green</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6984</th>\n",
       "      <td>202339</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Eric Bledsoe</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7001</th>\n",
       "      <td>203507</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Giannis Antetokounmpo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7040</th>\n",
       "      <td>201935</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>James Harden</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7061</th>\n",
       "      <td>202710</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Jimmy Butler</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7069</th>\n",
       "      <td>203954</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Joel Embiid</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7074</th>\n",
       "      <td>202322</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>John Wall</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7103</th>\n",
       "      <td>1626157</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Karl-Anthony Towns</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7112</th>\n",
       "      <td>201142</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kevin Durant</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7117</th>\n",
       "      <td>202691</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Klay Thompson</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7126</th>\n",
       "      <td>200768</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kyle Lowry</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7136</th>\n",
       "      <td>2544</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>LeBron James</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7154</th>\n",
       "      <td>201188</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Marc Gasol</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7188</th>\n",
       "      <td>1626167</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Myles Turner</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7198</th>\n",
       "      <td>203999</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Nikola Jokic</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7199</th>\n",
       "      <td>202703</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Nikola Mirotic</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7217</th>\n",
       "      <td>200794</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Paul Millsap</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7240</th>\n",
       "      <td>201566</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Russell Westbrook</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7257</th>\n",
       "      <td>201939</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Stephen Curry</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7303</th>\n",
       "      <td>203506</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Victor Oladipo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      PLAYER_ID       TEAM_ID            PLAYER_NAME  ALL_STAR  YEAR\n",
       "6885     201933  1.610613e+09          Blake Griffin       0.0  2017\n",
       "6891     203078  1.610613e+09           Bradley Beal       0.0  2017\n",
       "6931     201568  1.610613e+09       Danilo Gallinari       0.0  2017\n",
       "6947     201942  1.610613e+09          DeMar DeRozan       0.0  2017\n",
       "6948     202326  1.610613e+09       DeMarcus Cousins       0.0  2017\n",
       "6961    1626164  1.610613e+09           Devin Booker       0.0  2017\n",
       "6973     203110  1.610613e+09         Draymond Green       0.0  2017\n",
       "6984     202339  1.610613e+09           Eric Bledsoe       0.0  2017\n",
       "7001     203507  1.610613e+09  Giannis Antetokounmpo       0.0  2017\n",
       "7040     201935  1.610613e+09           James Harden       0.0  2017\n",
       "7061     202710  1.610613e+09           Jimmy Butler       0.0  2017\n",
       "7069     203954  1.610613e+09            Joel Embiid       0.0  2017\n",
       "7074     202322  1.610613e+09              John Wall       0.0  2017\n",
       "7103    1626157  1.610613e+09     Karl-Anthony Towns       0.0  2017\n",
       "7112     201142  1.610613e+09           Kevin Durant       0.0  2017\n",
       "7117     202691  1.610613e+09          Klay Thompson       0.0  2017\n",
       "7126     200768  1.610613e+09             Kyle Lowry       0.0  2017\n",
       "7136       2544  1.610613e+09           LeBron James       0.0  2017\n",
       "7154     201188  1.610613e+09             Marc Gasol       0.0  2017\n",
       "7188    1626167  1.610613e+09           Myles Turner       0.0  2017\n",
       "7198     203999  1.610613e+09           Nikola Jokic       0.0  2017\n",
       "7199     202703  1.610613e+09         Nikola Mirotic       0.0  2017\n",
       "7217     200794  1.610613e+09           Paul Millsap       0.0  2017\n",
       "7240     201566  1.610613e+09      Russell Westbrook       0.0  2017\n",
       "7257     201939  1.610613e+09          Stephen Curry       0.0  2017\n",
       "7303     203506  1.610613e+09         Victor Oladipo       0.0  2017"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_label_test.iloc[knn_predict == 1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## NB"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn import naive_bayes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "预测，这里用不用归一化的数据没有区别："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "nb_predict = naive_bayes.GaussianNB().fit(df_data_train, \n",
    "                                          df_label_train.ALL_STAR).predict(df_data_test)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "选中了："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "69.0"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum(nb_predict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PLAYER_ID</th>\n",
       "      <th>TEAM_ID</th>\n",
       "      <th>PLAYER_NAME</th>\n",
       "      <th>ALL_STAR</th>\n",
       "      <th>YEAR</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6851</th>\n",
       "      <td>203932</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Aaron Gordon</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6854</th>\n",
       "      <td>201143</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Al Horford</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6866</th>\n",
       "      <td>203083</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Andre Drummond</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6871</th>\n",
       "      <td>203952</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Andrew Wiggins</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6873</th>\n",
       "      <td>203076</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Anthony Davis</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6883</th>\n",
       "      <td>1627732</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Ben Simmons</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6885</th>\n",
       "      <td>201933</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Blake Griffin</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6891</th>\n",
       "      <td>203078</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Bradley Beal</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6893</th>\n",
       "      <td>1627742</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Brandon Ingram</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6902</th>\n",
       "      <td>203468</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>CJ McCollum</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6906</th>\n",
       "      <td>2546</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Carmelo Anthony</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6913</th>\n",
       "      <td>101108</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Chris Paul</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6914</th>\n",
       "      <td>203991</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Clint Capela</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6921</th>\n",
       "      <td>1626156</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>D'Angelo Russell</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6926</th>\n",
       "      <td>203081</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Damian Lillard</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6947</th>\n",
       "      <td>201942</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>DeMar DeRozan</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6948</th>\n",
       "      <td>202326</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>DeMarcus Cousins</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6953</th>\n",
       "      <td>203471</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Dennis Schroder</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6961</th>\n",
       "      <td>1626164</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Devin Booker</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6969</th>\n",
       "      <td>1628378</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Donovan Mitchell</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6975</th>\n",
       "      <td>2730</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Dwight Howard</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6984</th>\n",
       "      <td>202339</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Eric Bledsoe</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6985</th>\n",
       "      <td>201569</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Eric Gordon</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6988</th>\n",
       "      <td>203095</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Evan Fournier</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6996</th>\n",
       "      <td>203914</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Gary Harris</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7001</th>\n",
       "      <td>203507</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Giannis Antetokounmpo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7002</th>\n",
       "      <td>201609</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Goran Dragic</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7007</th>\n",
       "      <td>203084</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Harrison Barnes</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7008</th>\n",
       "      <td>202355</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Hassan Whiteside</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7040</th>\n",
       "      <td>201935</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>James Harden</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7112</th>\n",
       "      <td>201142</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kevin Durant</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7113</th>\n",
       "      <td>201567</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kevin Love</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7116</th>\n",
       "      <td>203114</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Khris Middleton</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7117</th>\n",
       "      <td>202691</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Klay Thompson</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7121</th>\n",
       "      <td>204001</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kristaps Porzingis</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7125</th>\n",
       "      <td>1628398</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kyle Kuzma</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7126</th>\n",
       "      <td>200768</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kyle Lowry</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7129</th>\n",
       "      <td>202681</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kyrie Irving</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7130</th>\n",
       "      <td>200746</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>LaMarcus Aldridge</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7136</th>\n",
       "      <td>2544</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>LeBron James</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7140</th>\n",
       "      <td>101150</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Lou Williams</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7154</th>\n",
       "      <td>201188</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Marc Gasol</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7178</th>\n",
       "      <td>201144</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Mike Conley</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7188</th>\n",
       "      <td>1626167</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Myles Turner</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7198</th>\n",
       "      <td>203999</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Nikola Jokic</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7199</th>\n",
       "      <td>202703</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Nikola Mirotic</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7200</th>\n",
       "      <td>202696</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Nikola Vucevic</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7216</th>\n",
       "      <td>202331</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Paul George</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7217</th>\n",
       "      <td>200794</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Paul Millsap</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7228</th>\n",
       "      <td>202704</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Reggie Jackson</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7236</th>\n",
       "      <td>1626178</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Rondae Hollis-Jefferson</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7240</th>\n",
       "      <td>201566</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Russell Westbrook</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7257</th>\n",
       "      <td>201939</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Stephen Curry</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7262</th>\n",
       "      <td>203933</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>TJ Warren</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7274</th>\n",
       "      <td>203501</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Tim Hardaway Jr.</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7277</th>\n",
       "      <td>202699</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Tobias Harris</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7298</th>\n",
       "      <td>201936</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Tyreke Evans</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7303</th>\n",
       "      <td>203506</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Victor Oladipo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7311</th>\n",
       "      <td>203115</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Will Barton</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7318</th>\n",
       "      <td>2216</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Zach Randolph</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>69 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "      PLAYER_ID       TEAM_ID              PLAYER_NAME  ALL_STAR  YEAR\n",
       "6851     203932  1.610613e+09             Aaron Gordon       0.0  2017\n",
       "6854     201143  1.610613e+09               Al Horford       0.0  2017\n",
       "6866     203083  1.610613e+09           Andre Drummond       0.0  2017\n",
       "6871     203952  1.610613e+09           Andrew Wiggins       0.0  2017\n",
       "6873     203076  1.610613e+09            Anthony Davis       0.0  2017\n",
       "6883    1627732  1.610613e+09              Ben Simmons       0.0  2017\n",
       "6885     201933  1.610613e+09            Blake Griffin       0.0  2017\n",
       "6891     203078  1.610613e+09             Bradley Beal       0.0  2017\n",
       "6893    1627742  1.610613e+09           Brandon Ingram       0.0  2017\n",
       "6902     203468  1.610613e+09              CJ McCollum       0.0  2017\n",
       "6906       2546  1.610613e+09          Carmelo Anthony       0.0  2017\n",
       "6913     101108  1.610613e+09               Chris Paul       0.0  2017\n",
       "6914     203991  1.610613e+09             Clint Capela       0.0  2017\n",
       "6921    1626156  1.610613e+09         D'Angelo Russell       0.0  2017\n",
       "6926     203081  1.610613e+09           Damian Lillard       0.0  2017\n",
       "6947     201942  1.610613e+09            DeMar DeRozan       0.0  2017\n",
       "6948     202326  1.610613e+09         DeMarcus Cousins       0.0  2017\n",
       "6953     203471  1.610613e+09          Dennis Schroder       0.0  2017\n",
       "6961    1626164  1.610613e+09             Devin Booker       0.0  2017\n",
       "6969    1628378  1.610613e+09         Donovan Mitchell       0.0  2017\n",
       "6975       2730  1.610613e+09            Dwight Howard       0.0  2017\n",
       "6984     202339  1.610613e+09             Eric Bledsoe       0.0  2017\n",
       "6985     201569  1.610613e+09              Eric Gordon       0.0  2017\n",
       "6988     203095  1.610613e+09            Evan Fournier       0.0  2017\n",
       "6996     203914  1.610613e+09              Gary Harris       0.0  2017\n",
       "7001     203507  1.610613e+09    Giannis Antetokounmpo       0.0  2017\n",
       "7002     201609  1.610613e+09             Goran Dragic       0.0  2017\n",
       "7007     203084  1.610613e+09          Harrison Barnes       0.0  2017\n",
       "7008     202355  1.610613e+09         Hassan Whiteside       0.0  2017\n",
       "7040     201935  1.610613e+09             James Harden       0.0  2017\n",
       "...         ...           ...                      ...       ...   ...\n",
       "7112     201142  1.610613e+09             Kevin Durant       0.0  2017\n",
       "7113     201567  1.610613e+09               Kevin Love       0.0  2017\n",
       "7116     203114  1.610613e+09          Khris Middleton       0.0  2017\n",
       "7117     202691  1.610613e+09            Klay Thompson       0.0  2017\n",
       "7121     204001  1.610613e+09       Kristaps Porzingis       0.0  2017\n",
       "7125    1628398  1.610613e+09               Kyle Kuzma       0.0  2017\n",
       "7126     200768  1.610613e+09               Kyle Lowry       0.0  2017\n",
       "7129     202681  1.610613e+09             Kyrie Irving       0.0  2017\n",
       "7130     200746  1.610613e+09        LaMarcus Aldridge       0.0  2017\n",
       "7136       2544  1.610613e+09             LeBron James       0.0  2017\n",
       "7140     101150  1.610613e+09             Lou Williams       0.0  2017\n",
       "7154     201188  1.610613e+09               Marc Gasol       0.0  2017\n",
       "7178     201144  1.610613e+09              Mike Conley       0.0  2017\n",
       "7188    1626167  1.610613e+09             Myles Turner       0.0  2017\n",
       "7198     203999  1.610613e+09             Nikola Jokic       0.0  2017\n",
       "7199     202703  1.610613e+09           Nikola Mirotic       0.0  2017\n",
       "7200     202696  1.610613e+09           Nikola Vucevic       0.0  2017\n",
       "7216     202331  1.610613e+09              Paul George       0.0  2017\n",
       "7217     200794  1.610613e+09             Paul Millsap       0.0  2017\n",
       "7228     202704  1.610613e+09           Reggie Jackson       0.0  2017\n",
       "7236    1626178  1.610613e+09  Rondae Hollis-Jefferson       0.0  2017\n",
       "7240     201566  1.610613e+09        Russell Westbrook       0.0  2017\n",
       "7257     201939  1.610613e+09            Stephen Curry       0.0  2017\n",
       "7262     203933  1.610613e+09                TJ Warren       0.0  2017\n",
       "7274     203501  1.610613e+09         Tim Hardaway Jr.       0.0  2017\n",
       "7277     202699  1.610613e+09            Tobias Harris       0.0  2017\n",
       "7298     201936  1.610613e+09             Tyreke Evans       0.0  2017\n",
       "7303     203506  1.610613e+09           Victor Oladipo       0.0  2017\n",
       "7311     203115  1.610613e+09              Will Barton       0.0  2017\n",
       "7318       2216  1.610613e+09            Zach Randolph       0.0  2017\n",
       "\n",
       "[69 rows x 5 columns]"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_label_test.iloc[nb_predict == 1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## DT"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn import tree"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "预测，用原始特征："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "dt_predict = tree.DecisionTreeClassifier().fit(df_data_train, \n",
    "                                               df_label_train.ALL_STAR).predict(df_data_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "31.0"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum(dt_predict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PLAYER_ID</th>\n",
       "      <th>TEAM_ID</th>\n",
       "      <th>PLAYER_NAME</th>\n",
       "      <th>ALL_STAR</th>\n",
       "      <th>YEAR</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6866</th>\n",
       "      <td>203083</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Andre Drummond</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6873</th>\n",
       "      <td>203076</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Anthony Davis</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6883</th>\n",
       "      <td>1627732</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Ben Simmons</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6885</th>\n",
       "      <td>201933</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Blake Griffin</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6902</th>\n",
       "      <td>203468</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>CJ McCollum</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6906</th>\n",
       "      <td>2546</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Carmelo Anthony</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6914</th>\n",
       "      <td>203991</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Clint Capela</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6921</th>\n",
       "      <td>1626156</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>D'Angelo Russell</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6926</th>\n",
       "      <td>203081</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Damian Lillard</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6973</th>\n",
       "      <td>203110</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Draymond Green</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6985</th>\n",
       "      <td>201569</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Eric Gordon</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7001</th>\n",
       "      <td>203507</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Giannis Antetokounmpo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7040</th>\n",
       "      <td>201935</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>James Harden</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7058</th>\n",
       "      <td>202391</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Jeremy Lin</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7069</th>\n",
       "      <td>203954</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Joel Embiid</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7112</th>\n",
       "      <td>201142</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kevin Durant</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7116</th>\n",
       "      <td>203114</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Khris Middleton</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7117</th>\n",
       "      <td>202691</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Klay Thompson</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7121</th>\n",
       "      <td>204001</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kristaps Porzingis</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7126</th>\n",
       "      <td>200768</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kyle Lowry</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7129</th>\n",
       "      <td>202681</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kyrie Irving</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7130</th>\n",
       "      <td>200746</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>LaMarcus Aldridge</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7136</th>\n",
       "      <td>2544</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>LeBron James</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7158</th>\n",
       "      <td>202694</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Marcus Morris</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7198</th>\n",
       "      <td>203999</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Nikola Jokic</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7200</th>\n",
       "      <td>202696</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Nikola Vucevic</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7216</th>\n",
       "      <td>202331</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Paul George</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7240</th>\n",
       "      <td>201566</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Russell Westbrook</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7257</th>\n",
       "      <td>201939</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Stephen Curry</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7298</th>\n",
       "      <td>201936</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Tyreke Evans</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7303</th>\n",
       "      <td>203506</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Victor Oladipo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      PLAYER_ID       TEAM_ID            PLAYER_NAME  ALL_STAR  YEAR\n",
       "6866     203083  1.610613e+09         Andre Drummond       0.0  2017\n",
       "6873     203076  1.610613e+09          Anthony Davis       0.0  2017\n",
       "6883    1627732  1.610613e+09            Ben Simmons       0.0  2017\n",
       "6885     201933  1.610613e+09          Blake Griffin       0.0  2017\n",
       "6902     203468  1.610613e+09            CJ McCollum       0.0  2017\n",
       "6906       2546  1.610613e+09        Carmelo Anthony       0.0  2017\n",
       "6914     203991  1.610613e+09           Clint Capela       0.0  2017\n",
       "6921    1626156  1.610613e+09       D'Angelo Russell       0.0  2017\n",
       "6926     203081  1.610613e+09         Damian Lillard       0.0  2017\n",
       "6973     203110  1.610613e+09         Draymond Green       0.0  2017\n",
       "6985     201569  1.610613e+09            Eric Gordon       0.0  2017\n",
       "7001     203507  1.610613e+09  Giannis Antetokounmpo       0.0  2017\n",
       "7040     201935  1.610613e+09           James Harden       0.0  2017\n",
       "7058     202391  1.610613e+09             Jeremy Lin       0.0  2017\n",
       "7069     203954  1.610613e+09            Joel Embiid       0.0  2017\n",
       "7112     201142  1.610613e+09           Kevin Durant       0.0  2017\n",
       "7116     203114  1.610613e+09        Khris Middleton       0.0  2017\n",
       "7117     202691  1.610613e+09          Klay Thompson       0.0  2017\n",
       "7121     204001  1.610613e+09     Kristaps Porzingis       0.0  2017\n",
       "7126     200768  1.610613e+09             Kyle Lowry       0.0  2017\n",
       "7129     202681  1.610613e+09           Kyrie Irving       0.0  2017\n",
       "7130     200746  1.610613e+09      LaMarcus Aldridge       0.0  2017\n",
       "7136       2544  1.610613e+09           LeBron James       0.0  2017\n",
       "7158     202694  1.610613e+09          Marcus Morris       0.0  2017\n",
       "7198     203999  1.610613e+09           Nikola Jokic       0.0  2017\n",
       "7200     202696  1.610613e+09         Nikola Vucevic       0.0  2017\n",
       "7216     202331  1.610613e+09            Paul George       0.0  2017\n",
       "7240     201566  1.610613e+09      Russell Westbrook       0.0  2017\n",
       "7257     201939  1.610613e+09          Stephen Curry       0.0  2017\n",
       "7298     201936  1.610613e+09           Tyreke Evans       0.0  2017\n",
       "7303     203506  1.610613e+09         Victor Oladipo       0.0  2017"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_label_test.iloc[dt_predict == 1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "归一化特征："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "dt_predict = tree.DecisionTreeClassifier().fit(df_data_norm_train, \n",
    "                                               df_label_train.ALL_STAR).predict(df_data_norm_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "29.0"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum(dt_predict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PLAYER_ID</th>\n",
       "      <th>TEAM_ID</th>\n",
       "      <th>PLAYER_NAME</th>\n",
       "      <th>ALL_STAR</th>\n",
       "      <th>YEAR</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6866</th>\n",
       "      <td>203083</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Andre Drummond</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6873</th>\n",
       "      <td>203076</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Anthony Davis</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6883</th>\n",
       "      <td>1627732</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Ben Simmons</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6885</th>\n",
       "      <td>201933</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Blake Griffin</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6902</th>\n",
       "      <td>203468</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>CJ McCollum</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6906</th>\n",
       "      <td>2546</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Carmelo Anthony</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6913</th>\n",
       "      <td>101108</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Chris Paul</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6921</th>\n",
       "      <td>1626156</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>D'Angelo Russell</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6926</th>\n",
       "      <td>203081</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Damian Lillard</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6944</th>\n",
       "      <td>201599</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>DeAndre Jordan</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6985</th>\n",
       "      <td>201569</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Eric Gordon</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7001</th>\n",
       "      <td>203507</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Giannis Antetokounmpo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7007</th>\n",
       "      <td>203084</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Harrison Barnes</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7040</th>\n",
       "      <td>201935</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>James Harden</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7054</th>\n",
       "      <td>201952</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Jeff Teague</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7069</th>\n",
       "      <td>203954</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Joel Embiid</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7074</th>\n",
       "      <td>202322</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>John Wall</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7112</th>\n",
       "      <td>201142</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kevin Durant</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7116</th>\n",
       "      <td>203114</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Khris Middleton</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7117</th>\n",
       "      <td>202691</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Klay Thompson</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7129</th>\n",
       "      <td>202681</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kyrie Irving</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7130</th>\n",
       "      <td>200746</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>LaMarcus Aldridge</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7136</th>\n",
       "      <td>2544</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>LeBron James</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7198</th>\n",
       "      <td>203999</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Nikola Jokic</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7216</th>\n",
       "      <td>202331</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Paul George</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7240</th>\n",
       "      <td>201566</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Russell Westbrook</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7257</th>\n",
       "      <td>201939</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Stephen Curry</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7298</th>\n",
       "      <td>201936</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Tyreke Evans</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7303</th>\n",
       "      <td>203506</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Victor Oladipo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      PLAYER_ID       TEAM_ID            PLAYER_NAME  ALL_STAR  YEAR\n",
       "6866     203083  1.610613e+09         Andre Drummond       0.0  2017\n",
       "6873     203076  1.610613e+09          Anthony Davis       0.0  2017\n",
       "6883    1627732  1.610613e+09            Ben Simmons       0.0  2017\n",
       "6885     201933  1.610613e+09          Blake Griffin       0.0  2017\n",
       "6902     203468  1.610613e+09            CJ McCollum       0.0  2017\n",
       "6906       2546  1.610613e+09        Carmelo Anthony       0.0  2017\n",
       "6913     101108  1.610613e+09             Chris Paul       0.0  2017\n",
       "6921    1626156  1.610613e+09       D'Angelo Russell       0.0  2017\n",
       "6926     203081  1.610613e+09         Damian Lillard       0.0  2017\n",
       "6944     201599  1.610613e+09         DeAndre Jordan       0.0  2017\n",
       "6985     201569  1.610613e+09            Eric Gordon       0.0  2017\n",
       "7001     203507  1.610613e+09  Giannis Antetokounmpo       0.0  2017\n",
       "7007     203084  1.610613e+09        Harrison Barnes       0.0  2017\n",
       "7040     201935  1.610613e+09           James Harden       0.0  2017\n",
       "7054     201952  1.610613e+09            Jeff Teague       0.0  2017\n",
       "7069     203954  1.610613e+09            Joel Embiid       0.0  2017\n",
       "7074     202322  1.610613e+09              John Wall       0.0  2017\n",
       "7112     201142  1.610613e+09           Kevin Durant       0.0  2017\n",
       "7116     203114  1.610613e+09        Khris Middleton       0.0  2017\n",
       "7117     202691  1.610613e+09          Klay Thompson       0.0  2017\n",
       "7129     202681  1.610613e+09           Kyrie Irving       0.0  2017\n",
       "7130     200746  1.610613e+09      LaMarcus Aldridge       0.0  2017\n",
       "7136       2544  1.610613e+09           LeBron James       0.0  2017\n",
       "7198     203999  1.610613e+09           Nikola Jokic       0.0  2017\n",
       "7216     202331  1.610613e+09            Paul George       0.0  2017\n",
       "7240     201566  1.610613e+09      Russell Westbrook       0.0  2017\n",
       "7257     201939  1.610613e+09          Stephen Curry       0.0  2017\n",
       "7298     201936  1.610613e+09           Tyreke Evans       0.0  2017\n",
       "7303     203506  1.610613e+09         Victor Oladipo       0.0  2017"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_label_test.iloc[dt_predict == 1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## DNN"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "神经网络用keras实现。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 模型1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Using TensorFlow backend.\n"
     ]
    }
   ],
   "source": [
    "from keras.layers import *\n",
    "from keras.models import Sequential, Model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [],
   "source": [
    "dim = df_data_train.shape[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "model1 = Sequential()\n",
    "model1.add(Dense(100, input_dim=dim, activation=\"tanh\"))\n",
    "model1.add(Dropout(0.5))\n",
    "model1.add(Dense(2, activation=\"softmax\"))\n",
    "\n",
    "model1.compile(loss=\"sparse_categorical_crossentropy\", optimizer=\"rmsprop\", metrics=[\"accuracy\"])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "为了训练模型，我们需要将数据随机打乱："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "idx = range(df_data_train.shape[0])\n",
    "np.random.shuffle(idx)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "然后按照打乱的顺序，切出20%的数据作为验证集，训练30轮，并预测。\n",
    "\n",
    "先使用原始特征训练："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train on 5480 samples, validate on 1370 samples\n",
      "Epoch 1/30\n",
      "5480/5480 [==============================] - 1s 132us/step - loss: 0.1859 - acc: 0.9403 - val_loss: 0.1194 - val_acc: 0.9547\n",
      "Epoch 2/30\n",
      "5480/5480 [==============================] - 0s 57us/step - loss: 0.1342 - acc: 0.9542 - val_loss: 0.1186 - val_acc: 0.9533\n",
      "Epoch 3/30\n",
      "5480/5480 [==============================] - 0s 57us/step - loss: 0.1281 - acc: 0.9551 - val_loss: 0.1122 - val_acc: 0.9562\n",
      "Epoch 4/30\n",
      "5480/5480 [==============================] - 0s 58us/step - loss: 0.1113 - acc: 0.9608 - val_loss: 0.1017 - val_acc: 0.9642\n",
      "Epoch 5/30\n",
      "5480/5480 [==============================] - 0s 56us/step - loss: 0.1129 - acc: 0.9630 - val_loss: 0.1156 - val_acc: 0.9584\n",
      "Epoch 6/30\n",
      "5480/5480 [==============================] - 0s 55us/step - loss: 0.1160 - acc: 0.9617 - val_loss: 0.0991 - val_acc: 0.9613\n",
      "Epoch 7/30\n",
      "5480/5480 [==============================] - 0s 57us/step - loss: 0.1058 - acc: 0.9619 - val_loss: 0.0974 - val_acc: 0.9657\n",
      "Epoch 8/30\n",
      "5480/5480 [==============================] - 0s 57us/step - loss: 0.1096 - acc: 0.9626 - val_loss: 0.1052 - val_acc: 0.9628\n",
      "Epoch 9/30\n",
      "5480/5480 [==============================] - 0s 56us/step - loss: 0.1064 - acc: 0.9633 - val_loss: 0.1110 - val_acc: 0.9613\n",
      "Epoch 10/30\n",
      "5480/5480 [==============================] - 0s 56us/step - loss: 0.1015 - acc: 0.9655 - val_loss: 0.1160 - val_acc: 0.9606\n",
      "Epoch 11/30\n",
      "5480/5480 [==============================] - 0s 61us/step - loss: 0.1015 - acc: 0.9628 - val_loss: 0.1044 - val_acc: 0.9657\n",
      "Epoch 12/30\n",
      "5480/5480 [==============================] - 0s 59us/step - loss: 0.1035 - acc: 0.9644 - val_loss: 0.0962 - val_acc: 0.9664\n",
      "Epoch 13/30\n",
      "5480/5480 [==============================] - 0s 58us/step - loss: 0.1033 - acc: 0.9635 - val_loss: 0.1054 - val_acc: 0.9664\n",
      "Epoch 14/30\n",
      "5480/5480 [==============================] - 0s 56us/step - loss: 0.0983 - acc: 0.9651 - val_loss: 0.1054 - val_acc: 0.9657\n",
      "Epoch 15/30\n",
      "5480/5480 [==============================] - 0s 50us/step - loss: 0.1020 - acc: 0.9679 - val_loss: 0.0973 - val_acc: 0.9664\n",
      "Epoch 16/30\n",
      "5480/5480 [==============================] - 0s 57us/step - loss: 0.0925 - acc: 0.9657 - val_loss: 0.1171 - val_acc: 0.9642\n",
      "Epoch 17/30\n",
      "5480/5480 [==============================] - 0s 52us/step - loss: 0.0952 - acc: 0.9677 - val_loss: 0.1102 - val_acc: 0.9650\n",
      "Epoch 18/30\n",
      "5480/5480 [==============================] - 0s 54us/step - loss: 0.0975 - acc: 0.9653 - val_loss: 0.1075 - val_acc: 0.9635\n",
      "Epoch 19/30\n",
      "5480/5480 [==============================] - 0s 54us/step - loss: 0.1068 - acc: 0.9644 - val_loss: 0.1038 - val_acc: 0.9672\n",
      "Epoch 20/30\n",
      "5480/5480 [==============================] - 0s 56us/step - loss: 0.1005 - acc: 0.9664 - val_loss: 0.1150 - val_acc: 0.9635\n",
      "Epoch 21/30\n",
      "5480/5480 [==============================] - 0s 49us/step - loss: 0.1014 - acc: 0.9684 - val_loss: 0.1126 - val_acc: 0.9628\n",
      "Epoch 22/30\n",
      "5480/5480 [==============================] - 0s 50us/step - loss: 0.1081 - acc: 0.9630 - val_loss: 0.1113 - val_acc: 0.9672\n",
      "Epoch 23/30\n",
      "5480/5480 [==============================] - 0s 51us/step - loss: 0.0998 - acc: 0.9664 - val_loss: 0.1074 - val_acc: 0.9642\n",
      "Epoch 24/30\n",
      "5480/5480 [==============================] - 0s 50us/step - loss: 0.0955 - acc: 0.9668 - val_loss: 0.1102 - val_acc: 0.9635\n",
      "Epoch 25/30\n",
      "5480/5480 [==============================] - 0s 51us/step - loss: 0.0969 - acc: 0.9681 - val_loss: 0.1023 - val_acc: 0.9657\n",
      "Epoch 26/30\n",
      "5480/5480 [==============================] - 0s 49us/step - loss: 0.0970 - acc: 0.9659 - val_loss: 0.1058 - val_acc: 0.9679\n",
      "Epoch 27/30\n",
      "5480/5480 [==============================] - 0s 50us/step - loss: 0.0954 - acc: 0.9666 - val_loss: 0.1182 - val_acc: 0.9606\n",
      "Epoch 28/30\n",
      "5480/5480 [==============================] - 0s 51us/step - loss: 0.0973 - acc: 0.9681 - val_loss: 0.1061 - val_acc: 0.9672\n",
      "Epoch 29/30\n",
      "5480/5480 [==============================] - 0s 50us/step - loss: 0.1003 - acc: 0.9650 - val_loss: 0.1049 - val_acc: 0.9657\n",
      "Epoch 30/30\n",
      "5480/5480 [==============================] - 0s 51us/step - loss: 0.1023 - acc: 0.9668 - val_loss: 0.1055 - val_acc: 0.9657\n"
     ]
    }
   ],
   "source": [
    "hist = model1.fit(df_data_train.iloc[idx],  \n",
    "                  df_label_train.iloc[idx].ALL_STAR, \n",
    "                  validation_split=0.2,epochs=30, shuffle=True)\n",
    "dnn_predict = model1.predict_classes(df_data_test)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "最终的结果为："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "21"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum(dnn_predict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PLAYER_ID</th>\n",
       "      <th>TEAM_ID</th>\n",
       "      <th>PLAYER_NAME</th>\n",
       "      <th>ALL_STAR</th>\n",
       "      <th>YEAR</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6873</th>\n",
       "      <td>203076</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Anthony Davis</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6885</th>\n",
       "      <td>201933</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Blake Griffin</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6891</th>\n",
       "      <td>203078</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Bradley Beal</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6913</th>\n",
       "      <td>101108</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Chris Paul</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6926</th>\n",
       "      <td>203081</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Damian Lillard</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6947</th>\n",
       "      <td>201942</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>DeMar DeRozan</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6948</th>\n",
       "      <td>202326</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>DeMarcus Cousins</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7001</th>\n",
       "      <td>203507</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Giannis Antetokounmpo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7040</th>\n",
       "      <td>201935</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>James Harden</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7061</th>\n",
       "      <td>202710</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Jimmy Butler</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7069</th>\n",
       "      <td>203954</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Joel Embiid</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7074</th>\n",
       "      <td>202322</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>John Wall</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7103</th>\n",
       "      <td>1626157</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Karl-Anthony Towns</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7112</th>\n",
       "      <td>201142</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kevin Durant</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7121</th>\n",
       "      <td>204001</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kristaps Porzingis</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7129</th>\n",
       "      <td>202681</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kyrie Irving</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7130</th>\n",
       "      <td>200746</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>LaMarcus Aldridge</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7136</th>\n",
       "      <td>2544</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>LeBron James</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7240</th>\n",
       "      <td>201566</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Russell Westbrook</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7257</th>\n",
       "      <td>201939</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Stephen Curry</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7303</th>\n",
       "      <td>203506</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Victor Oladipo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      PLAYER_ID       TEAM_ID            PLAYER_NAME  ALL_STAR  YEAR\n",
       "6873     203076  1.610613e+09          Anthony Davis       0.0  2017\n",
       "6885     201933  1.610613e+09          Blake Griffin       0.0  2017\n",
       "6891     203078  1.610613e+09           Bradley Beal       0.0  2017\n",
       "6913     101108  1.610613e+09             Chris Paul       0.0  2017\n",
       "6926     203081  1.610613e+09         Damian Lillard       0.0  2017\n",
       "6947     201942  1.610613e+09          DeMar DeRozan       0.0  2017\n",
       "6948     202326  1.610613e+09       DeMarcus Cousins       0.0  2017\n",
       "7001     203507  1.610613e+09  Giannis Antetokounmpo       0.0  2017\n",
       "7040     201935  1.610613e+09           James Harden       0.0  2017\n",
       "7061     202710  1.610613e+09           Jimmy Butler       0.0  2017\n",
       "7069     203954  1.610613e+09            Joel Embiid       0.0  2017\n",
       "7074     202322  1.610613e+09              John Wall       0.0  2017\n",
       "7103    1626157  1.610613e+09     Karl-Anthony Towns       0.0  2017\n",
       "7112     201142  1.610613e+09           Kevin Durant       0.0  2017\n",
       "7121     204001  1.610613e+09     Kristaps Porzingis       0.0  2017\n",
       "7129     202681  1.610613e+09           Kyrie Irving       0.0  2017\n",
       "7130     200746  1.610613e+09      LaMarcus Aldridge       0.0  2017\n",
       "7136       2544  1.610613e+09           LeBron James       0.0  2017\n",
       "7240     201566  1.610613e+09      Russell Westbrook       0.0  2017\n",
       "7257     201939  1.610613e+09          Stephen Curry       0.0  2017\n",
       "7303     203506  1.610613e+09         Victor Oladipo       0.0  2017"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_label_test.iloc[dnn_predict == 1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "再使用归一化特征训练："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train on 5480 samples, validate on 1370 samples\n",
      "Epoch 1/30\n",
      "5480/5480 [==============================] - 1s 112us/step - loss: 0.4268 - acc: 0.8024 - val_loss: 0.1560 - val_acc: 0.9504\n",
      "Epoch 2/30\n",
      "5480/5480 [==============================] - 0s 51us/step - loss: 0.1474 - acc: 0.9458 - val_loss: 0.0894 - val_acc: 0.9693\n",
      "Epoch 3/30\n",
      "5480/5480 [==============================] - 0s 51us/step - loss: 0.1032 - acc: 0.9615 - val_loss: 0.0974 - val_acc: 0.9628\n",
      "Epoch 4/30\n",
      "5480/5480 [==============================] - 0s 50us/step - loss: 0.0952 - acc: 0.9648 - val_loss: 0.0860 - val_acc: 0.9672\n",
      "Epoch 5/30\n",
      "5480/5480 [==============================] - 0s 50us/step - loss: 0.0952 - acc: 0.9630 - val_loss: 0.0916 - val_acc: 0.9620\n",
      "Epoch 6/30\n",
      "5480/5480 [==============================] - 0s 51us/step - loss: 0.0911 - acc: 0.9668 - val_loss: 0.1044 - val_acc: 0.9577\n",
      "Epoch 7/30\n",
      "5480/5480 [==============================] - 0s 51us/step - loss: 0.0817 - acc: 0.9684 - val_loss: 0.1023 - val_acc: 0.9591\n",
      "Epoch 8/30\n",
      "5480/5480 [==============================] - 0s 51us/step - loss: 0.0906 - acc: 0.9648 - val_loss: 0.0986 - val_acc: 0.9657\n",
      "Epoch 9/30\n",
      "5480/5480 [==============================] - 0s 51us/step - loss: 0.0817 - acc: 0.9684 - val_loss: 0.1354 - val_acc: 0.9533\n",
      "Epoch 10/30\n",
      "5480/5480 [==============================] - 0s 50us/step - loss: 0.0851 - acc: 0.9646 - val_loss: 0.1013 - val_acc: 0.9599\n",
      "Epoch 11/30\n",
      "5480/5480 [==============================] - 0s 51us/step - loss: 0.0810 - acc: 0.9677 - val_loss: 0.0870 - val_acc: 0.9664\n",
      "Epoch 12/30\n",
      "5480/5480 [==============================] - 0s 49us/step - loss: 0.0809 - acc: 0.9672 - val_loss: 0.0973 - val_acc: 0.9635\n",
      "Epoch 13/30\n",
      "5480/5480 [==============================] - 0s 51us/step - loss: 0.0763 - acc: 0.9697 - val_loss: 0.1111 - val_acc: 0.9591\n",
      "Epoch 14/30\n",
      "5480/5480 [==============================] - 0s 51us/step - loss: 0.0770 - acc: 0.9714 - val_loss: 0.0929 - val_acc: 0.9635\n",
      "Epoch 15/30\n",
      "5480/5480 [==============================] - 0s 53us/step - loss: 0.0786 - acc: 0.9701 - val_loss: 0.0833 - val_acc: 0.9679\n",
      "Epoch 16/30\n",
      "5480/5480 [==============================] - 0s 52us/step - loss: 0.0722 - acc: 0.9699 - val_loss: 0.1030 - val_acc: 0.9599\n",
      "Epoch 17/30\n",
      "5480/5480 [==============================] - 0s 50us/step - loss: 0.0720 - acc: 0.9706 - val_loss: 0.0867 - val_acc: 0.9664\n",
      "Epoch 18/30\n",
      "5480/5480 [==============================] - 0s 50us/step - loss: 0.0713 - acc: 0.9741 - val_loss: 0.1001 - val_acc: 0.9635\n",
      "Epoch 19/30\n",
      "5480/5480 [==============================] - 0s 51us/step - loss: 0.0765 - acc: 0.9699 - val_loss: 0.0942 - val_acc: 0.9672\n",
      "Epoch 20/30\n",
      "5480/5480 [==============================] - 0s 51us/step - loss: 0.0723 - acc: 0.9715 - val_loss: 0.0930 - val_acc: 0.9657\n",
      "Epoch 21/30\n",
      "5480/5480 [==============================] - 0s 49us/step - loss: 0.0699 - acc: 0.9693 - val_loss: 0.0983 - val_acc: 0.9635\n",
      "Epoch 22/30\n",
      "5480/5480 [==============================] - 0s 50us/step - loss: 0.0680 - acc: 0.9719 - val_loss: 0.0986 - val_acc: 0.9613\n",
      "Epoch 23/30\n",
      "5480/5480 [==============================] - 0s 50us/step - loss: 0.0697 - acc: 0.9712 - val_loss: 0.0943 - val_acc: 0.9642\n",
      "Epoch 24/30\n",
      "5480/5480 [==============================] - 0s 54us/step - loss: 0.0686 - acc: 0.9728 - val_loss: 0.0901 - val_acc: 0.9708\n",
      "Epoch 25/30\n",
      "5480/5480 [==============================] - 0s 55us/step - loss: 0.0678 - acc: 0.9712 - val_loss: 0.1142 - val_acc: 0.9569\n",
      "Epoch 26/30\n",
      "5480/5480 [==============================] - 0s 54us/step - loss: 0.0672 - acc: 0.9714 - val_loss: 0.0912 - val_acc: 0.9657\n",
      "Epoch 27/30\n",
      "5480/5480 [==============================] - 0s 49us/step - loss: 0.0658 - acc: 0.9726 - val_loss: 0.0890 - val_acc: 0.9664\n",
      "Epoch 28/30\n",
      "5480/5480 [==============================] - 0s 50us/step - loss: 0.0668 - acc: 0.9719 - val_loss: 0.0859 - val_acc: 0.9672\n",
      "Epoch 29/30\n",
      "5480/5480 [==============================] - 0s 50us/step - loss: 0.0689 - acc: 0.9719 - val_loss: 0.0934 - val_acc: 0.9672\n",
      "Epoch 30/30\n",
      "5480/5480 [==============================] - 0s 50us/step - loss: 0.0678 - acc: 0.9726 - val_loss: 0.0863 - val_acc: 0.9686\n"
     ]
    }
   ],
   "source": [
    "model1 = Sequential()\n",
    "model1.add(Dense(100, input_dim=dim, activation=\"tanh\"))\n",
    "model1.add(Dropout(0.5))\n",
    "model1.add(Dense(2, activation=\"softmax\"))\n",
    "\n",
    "model1.compile(loss=\"sparse_categorical_crossentropy\", optimizer=\"rmsprop\", metrics=[\"accuracy\"])\n",
    "\n",
    "hist = model1.fit(df_data_norm_train.iloc[idx],  \n",
    "                  df_label_train.iloc[idx].ALL_STAR, \n",
    "                  validation_split=0.2,epochs=30, shuffle=True)\n",
    "dnn_predict = model1.predict_classes(df_data_norm_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "20"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sum(dnn_predict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PLAYER_ID</th>\n",
       "      <th>TEAM_ID</th>\n",
       "      <th>PLAYER_NAME</th>\n",
       "      <th>ALL_STAR</th>\n",
       "      <th>YEAR</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6854</th>\n",
       "      <td>201143</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Al Horford</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6873</th>\n",
       "      <td>203076</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Anthony Davis</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6891</th>\n",
       "      <td>203078</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Bradley Beal</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6926</th>\n",
       "      <td>203081</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Damian Lillard</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6947</th>\n",
       "      <td>201942</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>DeMar DeRozan</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6948</th>\n",
       "      <td>202326</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>DeMarcus Cousins</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7001</th>\n",
       "      <td>203507</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Giannis Antetokounmpo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7040</th>\n",
       "      <td>201935</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>James Harden</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7061</th>\n",
       "      <td>202710</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Jimmy Butler</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7069</th>\n",
       "      <td>203954</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Joel Embiid</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7103</th>\n",
       "      <td>1626157</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Karl-Anthony Towns</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7112</th>\n",
       "      <td>201142</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kevin Durant</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7113</th>\n",
       "      <td>201567</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kevin Love</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7121</th>\n",
       "      <td>204001</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kristaps Porzingis</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7129</th>\n",
       "      <td>202681</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kyrie Irving</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7130</th>\n",
       "      <td>200746</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>LaMarcus Aldridge</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7136</th>\n",
       "      <td>2544</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>LeBron James</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7240</th>\n",
       "      <td>201566</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Russell Westbrook</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7257</th>\n",
       "      <td>201939</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Stephen Curry</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7303</th>\n",
       "      <td>203506</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Victor Oladipo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      PLAYER_ID       TEAM_ID            PLAYER_NAME  ALL_STAR  YEAR\n",
       "6854     201143  1.610613e+09             Al Horford       0.0  2017\n",
       "6873     203076  1.610613e+09          Anthony Davis       0.0  2017\n",
       "6891     203078  1.610613e+09           Bradley Beal       0.0  2017\n",
       "6926     203081  1.610613e+09         Damian Lillard       0.0  2017\n",
       "6947     201942  1.610613e+09          DeMar DeRozan       0.0  2017\n",
       "6948     202326  1.610613e+09       DeMarcus Cousins       0.0  2017\n",
       "7001     203507  1.610613e+09  Giannis Antetokounmpo       0.0  2017\n",
       "7040     201935  1.610613e+09           James Harden       0.0  2017\n",
       "7061     202710  1.610613e+09           Jimmy Butler       0.0  2017\n",
       "7069     203954  1.610613e+09            Joel Embiid       0.0  2017\n",
       "7103    1626157  1.610613e+09     Karl-Anthony Towns       0.0  2017\n",
       "7112     201142  1.610613e+09           Kevin Durant       0.0  2017\n",
       "7113     201567  1.610613e+09             Kevin Love       0.0  2017\n",
       "7121     204001  1.610613e+09     Kristaps Porzingis       0.0  2017\n",
       "7129     202681  1.610613e+09           Kyrie Irving       0.0  2017\n",
       "7130     200746  1.610613e+09      LaMarcus Aldridge       0.0  2017\n",
       "7136       2544  1.610613e+09           LeBron James       0.0  2017\n",
       "7240     201566  1.610613e+09      Russell Westbrook       0.0  2017\n",
       "7257     201939  1.610613e+09          Stephen Curry       0.0  2017\n",
       "7303     203506  1.610613e+09         Victor Oladipo       0.0  2017"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_label_test.iloc[dnn_predict == 1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 模型2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "在模型2中，加入球队ID作为一维Embedding特征。\n",
    "\n",
    "先将球队和球员的ID序列化："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "team2idx = {v:i for i, v in enumerate(set(df_label.TEAM_ID))}\n",
    "player2idx = {v:i for i, v in enumerate(set(df_label.PLAYER_ID))}\n",
    "\n",
    "idx2team = {i:v for i, v in enumerate(set(df_label.TEAM_ID))}\n",
    "idx2player = {i:v for i, v in enumerate(set(df_label.PLAYER_ID))}\n",
    "\n",
    "df_label[\"TEAM_IDX\"] = [team2idx[i] for i in df_label.TEAM_ID]\n",
    "df_label[\"PLAYER_IDX\"] = [player2idx[i] for i in df_label.PLAYER_ID]\n",
    "\n",
    "df_label_test = df_label.loc[df_label.YEAR == 2017]\n",
    "df_label_train = df_label.loc[df_label.YEAR < 2017]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "构建模型，在原始数据上训练验证和预测："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train on 5480 samples, validate on 1370 samples\n",
      "Epoch 1/30\n",
      "5480/5480 [==============================] - 1s 167us/step - loss: 0.1865 - acc: 0.9434 - val_loss: 0.1278 - val_acc: 0.9511\n",
      "Epoch 2/30\n",
      "5480/5480 [==============================] - 0s 66us/step - loss: 0.1170 - acc: 0.9608 - val_loss: 0.0939 - val_acc: 0.9642\n",
      "Epoch 3/30\n",
      "5480/5480 [==============================] - 0s 65us/step - loss: 0.1112 - acc: 0.9582 - val_loss: 0.1276 - val_acc: 0.9555\n",
      "Epoch 4/30\n",
      "5480/5480 [==============================] - 0s 66us/step - loss: 0.1116 - acc: 0.9606 - val_loss: 0.1022 - val_acc: 0.9628\n",
      "Epoch 5/30\n",
      "5480/5480 [==============================] - 0s 66us/step - loss: 0.1054 - acc: 0.9613 - val_loss: 0.0986 - val_acc: 0.9664\n",
      "Epoch 6/30\n",
      "5480/5480 [==============================] - 0s 67us/step - loss: 0.1041 - acc: 0.9624 - val_loss: 0.0946 - val_acc: 0.9664\n",
      "Epoch 7/30\n",
      "5480/5480 [==============================] - 0s 66us/step - loss: 0.1017 - acc: 0.9641 - val_loss: 0.1027 - val_acc: 0.9650\n",
      "Epoch 8/30\n",
      "5480/5480 [==============================] - 0s 66us/step - loss: 0.1021 - acc: 0.9650 - val_loss: 0.1122 - val_acc: 0.9599\n",
      "Epoch 9/30\n",
      "5480/5480 [==============================] - 0s 65us/step - loss: 0.1051 - acc: 0.9639 - val_loss: 0.1059 - val_acc: 0.9686\n",
      "Epoch 10/30\n",
      "5480/5480 [==============================] - 0s 68us/step - loss: 0.0986 - acc: 0.9664 - val_loss: 0.1016 - val_acc: 0.9628\n",
      "Epoch 11/30\n",
      "5480/5480 [==============================] - 0s 66us/step - loss: 0.1020 - acc: 0.9648 - val_loss: 0.0988 - val_acc: 0.9679\n",
      "Epoch 12/30\n",
      "5480/5480 [==============================] - 0s 71us/step - loss: 0.0945 - acc: 0.9661 - val_loss: 0.1030 - val_acc: 0.9664\n",
      "Epoch 13/30\n",
      "5480/5480 [==============================] - 0s 68us/step - loss: 0.0994 - acc: 0.9648 - val_loss: 0.0988 - val_acc: 0.9679\n",
      "Epoch 14/30\n",
      "5480/5480 [==============================] - 0s 66us/step - loss: 0.0932 - acc: 0.9692 - val_loss: 0.1181 - val_acc: 0.9591\n",
      "Epoch 15/30\n",
      "5480/5480 [==============================] - 0s 74us/step - loss: 0.0951 - acc: 0.9668 - val_loss: 0.1285 - val_acc: 0.9620\n",
      "Epoch 16/30\n",
      "5480/5480 [==============================] - 0s 69us/step - loss: 0.1002 - acc: 0.9659 - val_loss: 0.1042 - val_acc: 0.9657\n",
      "Epoch 17/30\n",
      "5480/5480 [==============================] - 0s 67us/step - loss: 0.0930 - acc: 0.9682 - val_loss: 0.1034 - val_acc: 0.9657\n",
      "Epoch 18/30\n",
      "5480/5480 [==============================] - 0s 66us/step - loss: 0.0931 - acc: 0.9659 - val_loss: 0.1045 - val_acc: 0.9657\n",
      "Epoch 19/30\n",
      "5480/5480 [==============================] - 0s 66us/step - loss: 0.0934 - acc: 0.9651 - val_loss: 0.1072 - val_acc: 0.9613\n",
      "Epoch 20/30\n",
      "5480/5480 [==============================] - 0s 67us/step - loss: 0.0882 - acc: 0.9673 - val_loss: 0.1298 - val_acc: 0.9569\n",
      "Epoch 21/30\n",
      "5480/5480 [==============================] - 0s 72us/step - loss: 0.0939 - acc: 0.9662 - val_loss: 0.1255 - val_acc: 0.9613\n",
      "Epoch 22/30\n",
      "5480/5480 [==============================] - 0s 71us/step - loss: 0.0927 - acc: 0.9679 - val_loss: 0.1296 - val_acc: 0.9562\n",
      "Epoch 23/30\n",
      "5480/5480 [==============================] - 0s 67us/step - loss: 0.0936 - acc: 0.9686 - val_loss: 0.1047 - val_acc: 0.9650\n",
      "Epoch 24/30\n",
      "5480/5480 [==============================] - 0s 67us/step - loss: 0.0909 - acc: 0.9672 - val_loss: 0.1019 - val_acc: 0.9679\n",
      "Epoch 25/30\n",
      "5480/5480 [==============================] - 0s 67us/step - loss: 0.0904 - acc: 0.9682 - val_loss: 0.1141 - val_acc: 0.9657\n",
      "Epoch 26/30\n",
      "5480/5480 [==============================] - 0s 67us/step - loss: 0.0975 - acc: 0.9688 - val_loss: 0.1032 - val_acc: 0.9650\n",
      "Epoch 27/30\n",
      "5480/5480 [==============================] - 0s 66us/step - loss: 0.0944 - acc: 0.9664 - val_loss: 0.1040 - val_acc: 0.9650\n",
      "Epoch 28/30\n",
      "5480/5480 [==============================] - 0s 67us/step - loss: 0.0951 - acc: 0.9670 - val_loss: 0.1119 - val_acc: 0.9635\n",
      "Epoch 29/30\n",
      "5480/5480 [==============================] - 0s 67us/step - loss: 0.0970 - acc: 0.9682 - val_loss: 0.1097 - val_acc: 0.9628\n",
      "Epoch 30/30\n",
      "5480/5480 [==============================] - 0s 69us/step - loss: 0.0998 - acc: 0.9679 - val_loss: 0.1085 - val_acc: 0.9672\n"
     ]
    }
   ],
   "source": [
    "dim = df_data_train.shape[1]\n",
    "\n",
    "in_team = Input(shape=(1,))\n",
    "emb_team = Embedding(len(idx2team), 10)(in_team)\n",
    "\n",
    "emb_team = Flatten()(emb_team)\n",
    "in_real = Input(shape=(dim,))\n",
    "\n",
    "in_all = concatenate([in_real, emb_team])\n",
    "\n",
    "dense1 = Dense(200, activation=\"tanh\")(in_all)\n",
    "dense1 = Dropout(0.5)(dense1)\n",
    "out = Dense(2, activation=\"softmax\")(dense1)\n",
    "\n",
    "model2 = Model(inputs=[in_team, in_real], outputs=out)\n",
    "\n",
    "model2.compile(loss=\"sparse_categorical_crossentropy\", optimizer=\"rmsprop\", metrics=[\"accuracy\"])\n",
    "\n",
    "hist = model2.fit([df_label_train.TEAM_IDX, df_data_train.iloc[idx]],  \n",
    "                  df_label_train.iloc[idx].ALL_STAR, \n",
    "                  validation_split=0.2,epochs=30, shuffle=True)\n",
    "dnn_predict = model2.predict([df_label_test.TEAM_IDX, df_data_test]).argmax(axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PLAYER_ID</th>\n",
       "      <th>TEAM_ID</th>\n",
       "      <th>PLAYER_NAME</th>\n",
       "      <th>ALL_STAR</th>\n",
       "      <th>YEAR</th>\n",
       "      <th>TEAM_IDX</th>\n",
       "      <th>PLAYER_IDX</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6873</th>\n",
       "      <td>203076</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Anthony Davis</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>3</td>\n",
       "      <td>1346</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6885</th>\n",
       "      <td>201933</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Blake Griffin</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>9</td>\n",
       "      <td>1074</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6891</th>\n",
       "      <td>203078</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Bradley Beal</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>27</td>\n",
       "      <td>1348</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6913</th>\n",
       "      <td>101108</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Chris Paul</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>8</td>\n",
       "      <td>1110</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6926</th>\n",
       "      <td>203081</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Damian Lillard</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>20</td>\n",
       "      <td>1351</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6947</th>\n",
       "      <td>201942</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>DeMar DeRozan</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>24</td>\n",
       "      <td>1082</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6948</th>\n",
       "      <td>202326</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>DeMarcus Cousins</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>3</td>\n",
       "      <td>1138</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7001</th>\n",
       "      <td>203507</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Giannis Antetokounmpo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>12</td>\n",
       "      <td>1467</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7040</th>\n",
       "      <td>201935</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>James Harden</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>8</td>\n",
       "      <td>1076</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7061</th>\n",
       "      <td>202710</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Jimmy Butler</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>13</td>\n",
       "      <td>1262</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7069</th>\n",
       "      <td>203954</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Joel Embiid</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>18</td>\n",
       "      <td>1541</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7074</th>\n",
       "      <td>202322</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>John Wall</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>27</td>\n",
       "      <td>1134</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7103</th>\n",
       "      <td>1626157</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Karl-Anthony Towns</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>13</td>\n",
       "      <td>875</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7112</th>\n",
       "      <td>201142</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kevin Durant</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>7</td>\n",
       "      <td>955</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7121</th>\n",
       "      <td>204001</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kristaps Porzingis</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>15</td>\n",
       "      <td>1557</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7129</th>\n",
       "      <td>202681</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kyrie Irving</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>1</td>\n",
       "      <td>1234</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7130</th>\n",
       "      <td>200746</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>LaMarcus Aldridge</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>22</td>\n",
       "      <td>872</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7136</th>\n",
       "      <td>2544</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>LeBron James</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>2</td>\n",
       "      <td>660</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7240</th>\n",
       "      <td>201566</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Russell Westbrook</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>23</td>\n",
       "      <td>1015</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7257</th>\n",
       "      <td>201939</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Stephen Curry</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>7</td>\n",
       "      <td>1080</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7303</th>\n",
       "      <td>203506</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Victor Oladipo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>17</td>\n",
       "      <td>1466</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      PLAYER_ID       TEAM_ID            PLAYER_NAME  ALL_STAR  YEAR  \\\n",
       "6873     203076  1.610613e+09          Anthony Davis       0.0  2017   \n",
       "6885     201933  1.610613e+09          Blake Griffin       0.0  2017   \n",
       "6891     203078  1.610613e+09           Bradley Beal       0.0  2017   \n",
       "6913     101108  1.610613e+09             Chris Paul       0.0  2017   \n",
       "6926     203081  1.610613e+09         Damian Lillard       0.0  2017   \n",
       "6947     201942  1.610613e+09          DeMar DeRozan       0.0  2017   \n",
       "6948     202326  1.610613e+09       DeMarcus Cousins       0.0  2017   \n",
       "7001     203507  1.610613e+09  Giannis Antetokounmpo       0.0  2017   \n",
       "7040     201935  1.610613e+09           James Harden       0.0  2017   \n",
       "7061     202710  1.610613e+09           Jimmy Butler       0.0  2017   \n",
       "7069     203954  1.610613e+09            Joel Embiid       0.0  2017   \n",
       "7074     202322  1.610613e+09              John Wall       0.0  2017   \n",
       "7103    1626157  1.610613e+09     Karl-Anthony Towns       0.0  2017   \n",
       "7112     201142  1.610613e+09           Kevin Durant       0.0  2017   \n",
       "7121     204001  1.610613e+09     Kristaps Porzingis       0.0  2017   \n",
       "7129     202681  1.610613e+09           Kyrie Irving       0.0  2017   \n",
       "7130     200746  1.610613e+09      LaMarcus Aldridge       0.0  2017   \n",
       "7136       2544  1.610613e+09           LeBron James       0.0  2017   \n",
       "7240     201566  1.610613e+09      Russell Westbrook       0.0  2017   \n",
       "7257     201939  1.610613e+09          Stephen Curry       0.0  2017   \n",
       "7303     203506  1.610613e+09         Victor Oladipo       0.0  2017   \n",
       "\n",
       "      TEAM_IDX  PLAYER_IDX  \n",
       "6873         3        1346  \n",
       "6885         9        1074  \n",
       "6891        27        1348  \n",
       "6913         8        1110  \n",
       "6926        20        1351  \n",
       "6947        24        1082  \n",
       "6948         3        1138  \n",
       "7001        12        1467  \n",
       "7040         8        1076  \n",
       "7061        13        1262  \n",
       "7069        18        1541  \n",
       "7074        27        1134  \n",
       "7103        13         875  \n",
       "7112         7         955  \n",
       "7121        15        1557  \n",
       "7129         1        1234  \n",
       "7130        22         872  \n",
       "7136         2         660  \n",
       "7240        23        1015  \n",
       "7257         7        1080  \n",
       "7303        17        1466  "
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_label_test.iloc[dnn_predict == 1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "归一化数据上："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train on 5480 samples, validate on 1370 samples\n",
      "Epoch 1/30\n",
      "5480/5480 [==============================] - 1s 180us/step - loss: 0.2967 - acc: 0.8750 - val_loss: 0.1011 - val_acc: 0.9628\n",
      "Epoch 2/30\n",
      "5480/5480 [==============================] - 0s 71us/step - loss: 0.1137 - acc: 0.9580 - val_loss: 0.1138 - val_acc: 0.9518\n",
      "Epoch 3/30\n",
      "5480/5480 [==============================] - 0s 75us/step - loss: 0.0950 - acc: 0.9642 - val_loss: 0.1803 - val_acc: 0.9460\n",
      "Epoch 4/30\n",
      "5480/5480 [==============================] - 0s 71us/step - loss: 0.0912 - acc: 0.9641 - val_loss: 0.1007 - val_acc: 0.9599\n",
      "Epoch 5/30\n",
      "5480/5480 [==============================] - 0s 73us/step - loss: 0.0855 - acc: 0.9672 - val_loss: 0.0822 - val_acc: 0.9664\n",
      "Epoch 6/30\n",
      "5480/5480 [==============================] - 0s 77us/step - loss: 0.0851 - acc: 0.9672 - val_loss: 0.1293 - val_acc: 0.9577\n",
      "Epoch 7/30\n",
      "5480/5480 [==============================] - 0s 74us/step - loss: 0.0821 - acc: 0.9682 - val_loss: 0.1024 - val_acc: 0.9613\n",
      "Epoch 8/30\n",
      "5480/5480 [==============================] - 0s 72us/step - loss: 0.0779 - acc: 0.9666 - val_loss: 0.1168 - val_acc: 0.9569\n",
      "Epoch 9/30\n",
      "5480/5480 [==============================] - 0s 72us/step - loss: 0.0750 - acc: 0.9695 - val_loss: 0.0925 - val_acc: 0.9664\n",
      "Epoch 10/30\n",
      "5480/5480 [==============================] - 0s 71us/step - loss: 0.0745 - acc: 0.9712 - val_loss: 0.0961 - val_acc: 0.9584\n",
      "Epoch 11/30\n",
      "5480/5480 [==============================] - 0s 75us/step - loss: 0.0735 - acc: 0.9706 - val_loss: 0.1185 - val_acc: 0.9555\n",
      "Epoch 12/30\n",
      "5480/5480 [==============================] - 0s 76us/step - loss: 0.0755 - acc: 0.9692 - val_loss: 0.0937 - val_acc: 0.9657\n",
      "Epoch 13/30\n",
      "5480/5480 [==============================] - 0s 76us/step - loss: 0.0732 - acc: 0.9710 - val_loss: 0.0949 - val_acc: 0.9642\n",
      "Epoch 14/30\n",
      "5480/5480 [==============================] - 0s 79us/step - loss: 0.0710 - acc: 0.9723 - val_loss: 0.0862 - val_acc: 0.9657\n",
      "Epoch 15/30\n",
      "5480/5480 [==============================] - 0s 77us/step - loss: 0.0695 - acc: 0.9708 - val_loss: 0.0845 - val_acc: 0.9657\n",
      "Epoch 16/30\n",
      "5480/5480 [==============================] - 0s 70us/step - loss: 0.0669 - acc: 0.9728 - val_loss: 0.0932 - val_acc: 0.9635\n",
      "Epoch 17/30\n",
      "5480/5480 [==============================] - 0s 72us/step - loss: 0.0692 - acc: 0.9704 - val_loss: 0.0988 - val_acc: 0.9599\n",
      "Epoch 18/30\n",
      "5480/5480 [==============================] - 0s 73us/step - loss: 0.0632 - acc: 0.9732 - val_loss: 0.1019 - val_acc: 0.9613\n",
      "Epoch 19/30\n",
      "5480/5480 [==============================] - 0s 77us/step - loss: 0.0648 - acc: 0.9730 - val_loss: 0.1035 - val_acc: 0.9635\n",
      "Epoch 20/30\n",
      "5480/5480 [==============================] - 0s 77us/step - loss: 0.0630 - acc: 0.9746 - val_loss: 0.0934 - val_acc: 0.9628\n",
      "Epoch 21/30\n",
      "5480/5480 [==============================] - 0s 71us/step - loss: 0.0650 - acc: 0.9719 - val_loss: 0.0857 - val_acc: 0.9628\n",
      "Epoch 22/30\n",
      "5480/5480 [==============================] - 0s 70us/step - loss: 0.0623 - acc: 0.9752 - val_loss: 0.0904 - val_acc: 0.9679\n",
      "Epoch 23/30\n",
      "5480/5480 [==============================] - 0s 74us/step - loss: 0.0605 - acc: 0.9741 - val_loss: 0.0921 - val_acc: 0.9642\n",
      "Epoch 24/30\n",
      "5480/5480 [==============================] - 0s 79us/step - loss: 0.0621 - acc: 0.9748 - val_loss: 0.0875 - val_acc: 0.9650\n",
      "Epoch 25/30\n",
      "5480/5480 [==============================] - 0s 72us/step - loss: 0.0623 - acc: 0.9721 - val_loss: 0.0903 - val_acc: 0.9642\n",
      "Epoch 26/30\n",
      "5480/5480 [==============================] - 0s 75us/step - loss: 0.0630 - acc: 0.9752 - val_loss: 0.1270 - val_acc: 0.9547\n",
      "Epoch 27/30\n",
      "5480/5480 [==============================] - 0s 70us/step - loss: 0.0605 - acc: 0.9739 - val_loss: 0.0952 - val_acc: 0.9672\n",
      "Epoch 28/30\n",
      "5480/5480 [==============================] - 0s 74us/step - loss: 0.0589 - acc: 0.9776 - val_loss: 0.0978 - val_acc: 0.9657\n",
      "Epoch 29/30\n",
      "5480/5480 [==============================] - 0s 74us/step - loss: 0.0627 - acc: 0.9730 - val_loss: 0.0948 - val_acc: 0.9650\n",
      "Epoch 30/30\n",
      "5480/5480 [==============================] - 0s 73us/step - loss: 0.0601 - acc: 0.9735 - val_loss: 0.0948 - val_acc: 0.9635\n"
     ]
    }
   ],
   "source": [
    "dim = df_data_train.shape[1]\n",
    "\n",
    "in_team = Input(shape=(1,))\n",
    "emb_team = Embedding(len(idx2team), 10)(in_team)\n",
    "\n",
    "emb_team = Flatten()(emb_team)\n",
    "in_real = Input(shape=(dim,))\n",
    "\n",
    "in_all = concatenate([in_real, emb_team])\n",
    "\n",
    "dense1 = Dense(200, activation=\"tanh\")(in_all)\n",
    "dense1 = Dropout(0.5)(dense1)\n",
    "out = Dense(2, activation=\"softmax\")(dense1)\n",
    "\n",
    "model2 = Model(inputs=[in_team, in_real], outputs=out)\n",
    "\n",
    "model2.compile(loss=\"sparse_categorical_crossentropy\", optimizer=\"rmsprop\", metrics=[\"accuracy\"])\n",
    "\n",
    "hist = model2.fit([df_label_train.TEAM_IDX, df_data_norm_train.iloc[idx]],  \n",
    "                  df_label_train.iloc[idx].ALL_STAR, \n",
    "                  validation_split=0.2,epochs=30, shuffle=True)\n",
    "dnn_predict = model2.predict([df_label_test.TEAM_IDX, df_data_norm_test]).argmax(axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PLAYER_ID</th>\n",
       "      <th>TEAM_ID</th>\n",
       "      <th>PLAYER_NAME</th>\n",
       "      <th>ALL_STAR</th>\n",
       "      <th>YEAR</th>\n",
       "      <th>TEAM_IDX</th>\n",
       "      <th>PLAYER_IDX</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6854</th>\n",
       "      <td>201143</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Al Horford</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>1</td>\n",
       "      <td>956</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6873</th>\n",
       "      <td>203076</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Anthony Davis</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>3</td>\n",
       "      <td>1346</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6891</th>\n",
       "      <td>203078</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Bradley Beal</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>27</td>\n",
       "      <td>1348</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6913</th>\n",
       "      <td>101108</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Chris Paul</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>8</td>\n",
       "      <td>1110</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6926</th>\n",
       "      <td>203081</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Damian Lillard</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>20</td>\n",
       "      <td>1351</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6947</th>\n",
       "      <td>201942</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>DeMar DeRozan</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>24</td>\n",
       "      <td>1082</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6948</th>\n",
       "      <td>202326</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>DeMarcus Cousins</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>3</td>\n",
       "      <td>1138</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7001</th>\n",
       "      <td>203507</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Giannis Antetokounmpo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>12</td>\n",
       "      <td>1467</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7040</th>\n",
       "      <td>201935</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>James Harden</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>8</td>\n",
       "      <td>1076</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7061</th>\n",
       "      <td>202710</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Jimmy Butler</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>13</td>\n",
       "      <td>1262</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7069</th>\n",
       "      <td>203954</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Joel Embiid</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>18</td>\n",
       "      <td>1541</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7074</th>\n",
       "      <td>202322</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>John Wall</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>27</td>\n",
       "      <td>1134</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7103</th>\n",
       "      <td>1626157</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Karl-Anthony Towns</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>13</td>\n",
       "      <td>875</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7112</th>\n",
       "      <td>201142</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kevin Durant</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>7</td>\n",
       "      <td>955</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7113</th>\n",
       "      <td>201567</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kevin Love</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>2</td>\n",
       "      <td>1016</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7117</th>\n",
       "      <td>202691</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Klay Thompson</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>7</td>\n",
       "      <td>1244</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7121</th>\n",
       "      <td>204001</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kristaps Porzingis</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>15</td>\n",
       "      <td>1557</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7129</th>\n",
       "      <td>202681</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kyrie Irving</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>1</td>\n",
       "      <td>1234</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7130</th>\n",
       "      <td>200746</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>LaMarcus Aldridge</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>22</td>\n",
       "      <td>872</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7136</th>\n",
       "      <td>2544</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>LeBron James</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>2</td>\n",
       "      <td>660</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7198</th>\n",
       "      <td>203999</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Nikola Jokic</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>6</td>\n",
       "      <td>1556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7240</th>\n",
       "      <td>201566</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Russell Westbrook</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>23</td>\n",
       "      <td>1015</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7257</th>\n",
       "      <td>201939</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Stephen Curry</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>7</td>\n",
       "      <td>1080</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7303</th>\n",
       "      <td>203506</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Victor Oladipo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>17</td>\n",
       "      <td>1466</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      PLAYER_ID       TEAM_ID            PLAYER_NAME  ALL_STAR  YEAR  \\\n",
       "6854     201143  1.610613e+09             Al Horford       0.0  2017   \n",
       "6873     203076  1.610613e+09          Anthony Davis       0.0  2017   \n",
       "6891     203078  1.610613e+09           Bradley Beal       0.0  2017   \n",
       "6913     101108  1.610613e+09             Chris Paul       0.0  2017   \n",
       "6926     203081  1.610613e+09         Damian Lillard       0.0  2017   \n",
       "6947     201942  1.610613e+09          DeMar DeRozan       0.0  2017   \n",
       "6948     202326  1.610613e+09       DeMarcus Cousins       0.0  2017   \n",
       "7001     203507  1.610613e+09  Giannis Antetokounmpo       0.0  2017   \n",
       "7040     201935  1.610613e+09           James Harden       0.0  2017   \n",
       "7061     202710  1.610613e+09           Jimmy Butler       0.0  2017   \n",
       "7069     203954  1.610613e+09            Joel Embiid       0.0  2017   \n",
       "7074     202322  1.610613e+09              John Wall       0.0  2017   \n",
       "7103    1626157  1.610613e+09     Karl-Anthony Towns       0.0  2017   \n",
       "7112     201142  1.610613e+09           Kevin Durant       0.0  2017   \n",
       "7113     201567  1.610613e+09             Kevin Love       0.0  2017   \n",
       "7117     202691  1.610613e+09          Klay Thompson       0.0  2017   \n",
       "7121     204001  1.610613e+09     Kristaps Porzingis       0.0  2017   \n",
       "7129     202681  1.610613e+09           Kyrie Irving       0.0  2017   \n",
       "7130     200746  1.610613e+09      LaMarcus Aldridge       0.0  2017   \n",
       "7136       2544  1.610613e+09           LeBron James       0.0  2017   \n",
       "7198     203999  1.610613e+09           Nikola Jokic       0.0  2017   \n",
       "7240     201566  1.610613e+09      Russell Westbrook       0.0  2017   \n",
       "7257     201939  1.610613e+09          Stephen Curry       0.0  2017   \n",
       "7303     203506  1.610613e+09         Victor Oladipo       0.0  2017   \n",
       "\n",
       "      TEAM_IDX  PLAYER_IDX  \n",
       "6854         1         956  \n",
       "6873         3        1346  \n",
       "6891        27        1348  \n",
       "6913         8        1110  \n",
       "6926        20        1351  \n",
       "6947        24        1082  \n",
       "6948         3        1138  \n",
       "7001        12        1467  \n",
       "7040         8        1076  \n",
       "7061        13        1262  \n",
       "7069        18        1541  \n",
       "7074        27        1134  \n",
       "7103        13         875  \n",
       "7112         7         955  \n",
       "7113         2        1016  \n",
       "7117         7        1244  \n",
       "7121        15        1557  \n",
       "7129         1        1234  \n",
       "7130        22         872  \n",
       "7136         2         660  \n",
       "7198         6        1556  \n",
       "7240        23        1015  \n",
       "7257         7        1080  \n",
       "7303        17        1466  "
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_label_test.iloc[dnn_predict == 1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 模型3"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "可以再加入球员的ID作为Embedding特征，原始特征："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train on 5480 samples, validate on 1370 samples\n",
      "Epoch 1/30\n",
      "5480/5480 [==============================] - 1s 181us/step - loss: 0.1847 - acc: 0.9411 - val_loss: 0.1348 - val_acc: 0.9526\n",
      "Epoch 2/30\n",
      "5480/5480 [==============================] - 0s 78us/step - loss: 0.1256 - acc: 0.9538 - val_loss: 0.1103 - val_acc: 0.9562\n",
      "Epoch 3/30\n",
      "5480/5480 [==============================] - 0s 77us/step - loss: 0.1259 - acc: 0.9542 - val_loss: 0.0976 - val_acc: 0.9620\n",
      "Epoch 4/30\n",
      "5480/5480 [==============================] - 0s 81us/step - loss: 0.1061 - acc: 0.9617 - val_loss: 0.1329 - val_acc: 0.9562\n",
      "Epoch 5/30\n",
      "5480/5480 [==============================] - 0s 82us/step - loss: 0.1017 - acc: 0.9646 - val_loss: 0.0996 - val_acc: 0.9657\n",
      "Epoch 6/30\n",
      "5480/5480 [==============================] - 0s 80us/step - loss: 0.1019 - acc: 0.9646 - val_loss: 0.1060 - val_acc: 0.9613\n",
      "Epoch 7/30\n",
      "5480/5480 [==============================] - 0s 86us/step - loss: 0.1066 - acc: 0.9624 - val_loss: 0.0958 - val_acc: 0.9650\n",
      "Epoch 8/30\n",
      "5480/5480 [==============================] - 0s 77us/step - loss: 0.1006 - acc: 0.9659 - val_loss: 0.1383 - val_acc: 0.9547\n",
      "Epoch 9/30\n",
      "5480/5480 [==============================] - 0s 79us/step - loss: 0.1038 - acc: 0.9644 - val_loss: 0.1085 - val_acc: 0.9650\n",
      "Epoch 10/30\n",
      "5480/5480 [==============================] - 0s 80us/step - loss: 0.1037 - acc: 0.9635 - val_loss: 0.1136 - val_acc: 0.9664\n",
      "Epoch 11/30\n",
      "5480/5480 [==============================] - 0s 78us/step - loss: 0.0986 - acc: 0.9655 - val_loss: 0.1153 - val_acc: 0.9599\n",
      "Epoch 12/30\n",
      "5480/5480 [==============================] - 0s 79us/step - loss: 0.1021 - acc: 0.9608 - val_loss: 0.1017 - val_acc: 0.9693\n",
      "Epoch 13/30\n",
      "5480/5480 [==============================] - 0s 80us/step - loss: 0.0968 - acc: 0.9659 - val_loss: 0.1087 - val_acc: 0.9657\n",
      "Epoch 14/30\n",
      "5480/5480 [==============================] - 0s 78us/step - loss: 0.0978 - acc: 0.9620 - val_loss: 0.1013 - val_acc: 0.9657\n",
      "Epoch 15/30\n",
      "5480/5480 [==============================] - 0s 82us/step - loss: 0.0923 - acc: 0.9692 - val_loss: 0.1041 - val_acc: 0.9650\n",
      "Epoch 16/30\n",
      "5480/5480 [==============================] - 1s 95us/step - loss: 0.1001 - acc: 0.9666 - val_loss: 0.1076 - val_acc: 0.9664\n",
      "Epoch 17/30\n",
      "5480/5480 [==============================] - 0s 81us/step - loss: 0.0933 - acc: 0.9659 - val_loss: 0.1067 - val_acc: 0.9664\n",
      "Epoch 18/30\n",
      "5480/5480 [==============================] - 0s 77us/step - loss: 0.0954 - acc: 0.9657 - val_loss: 0.1157 - val_acc: 0.9591\n",
      "Epoch 19/30\n",
      "5480/5480 [==============================] - 0s 74us/step - loss: 0.0920 - acc: 0.9666 - val_loss: 0.1218 - val_acc: 0.9635\n",
      "Epoch 20/30\n",
      "5480/5480 [==============================] - 0s 73us/step - loss: 0.0930 - acc: 0.9690 - val_loss: 0.1095 - val_acc: 0.9635\n",
      "Epoch 21/30\n",
      "5480/5480 [==============================] - 0s 86us/step - loss: 0.0949 - acc: 0.9670 - val_loss: 0.1015 - val_acc: 0.9664\n",
      "Epoch 22/30\n",
      "5480/5480 [==============================] - 0s 80us/step - loss: 0.0985 - acc: 0.9690 - val_loss: 0.1112 - val_acc: 0.9620\n",
      "Epoch 23/30\n",
      "5480/5480 [==============================] - 0s 79us/step - loss: 0.0947 - acc: 0.9668 - val_loss: 0.1033 - val_acc: 0.9635\n",
      "Epoch 24/30\n",
      "5480/5480 [==============================] - 0s 78us/step - loss: 0.0936 - acc: 0.9673 - val_loss: 0.0992 - val_acc: 0.9664\n",
      "Epoch 25/30\n",
      "5480/5480 [==============================] - 0s 77us/step - loss: 0.0954 - acc: 0.9682 - val_loss: 0.1045 - val_acc: 0.9642\n",
      "Epoch 26/30\n",
      "5480/5480 [==============================] - 0s 83us/step - loss: 0.0951 - acc: 0.9682 - val_loss: 0.1102 - val_acc: 0.9679\n",
      "Epoch 27/30\n",
      "5480/5480 [==============================] - 1s 100us/step - loss: 0.0924 - acc: 0.9684 - val_loss: 0.1160 - val_acc: 0.9635\n",
      "Epoch 28/30\n",
      "5480/5480 [==============================] - 0s 87us/step - loss: 0.0909 - acc: 0.9684 - val_loss: 0.1032 - val_acc: 0.9672\n",
      "Epoch 29/30\n",
      "5480/5480 [==============================] - 1s 93us/step - loss: 0.0914 - acc: 0.9672 - val_loss: 0.1205 - val_acc: 0.9628\n",
      "Epoch 30/30\n",
      "5480/5480 [==============================] - 0s 82us/step - loss: 0.0940 - acc: 0.9684 - val_loss: 0.0956 - val_acc: 0.9672\n"
     ]
    }
   ],
   "source": [
    "dim = df_data_train.shape[1]\n",
    "\n",
    "in_team = Input(shape=(1,))\n",
    "emb_team = Embedding(len(idx2team), 10)(in_team)\n",
    "emb_team = Flatten()(emb_team)\n",
    "\n",
    "in_player = Input(shape=(1,))\n",
    "emb_player = Embedding(len(idx2player), 10)(in_player)\n",
    "emb_player = Flatten()(emb_player)\n",
    "\n",
    "in_real = Input(shape=(dim,))\n",
    "\n",
    "in_all = concatenate([in_real, emb_team, emb_player])\n",
    "\n",
    "dense1 = Dense(200, activation=\"tanh\")(in_all)\n",
    "dense1 = Dropout(0.5)(dense1)\n",
    "out = Dense(2, activation=\"softmax\")(dense1)\n",
    "\n",
    "model3 = Model(inputs=[in_team, in_player, in_real], outputs=out)\n",
    "\n",
    "model3.compile(loss=\"sparse_categorical_crossentropy\", optimizer=\"rmsprop\", metrics=[\"accuracy\"])\n",
    "\n",
    "hist = model3.fit([df_label_train.TEAM_IDX, df_label_train.PLAYER_IDX, df_data_train.iloc[idx]],  \n",
    "                  df_label_train.iloc[idx].ALL_STAR, \n",
    "                  validation_split=0.2,epochs=30, shuffle=True)\n",
    "dnn_predict = model3.predict([df_label_test.TEAM_IDX, df_label_test.PLAYER_IDX, df_data_test]).argmax(axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PLAYER_ID</th>\n",
       "      <th>TEAM_ID</th>\n",
       "      <th>PLAYER_NAME</th>\n",
       "      <th>ALL_STAR</th>\n",
       "      <th>YEAR</th>\n",
       "      <th>TEAM_IDX</th>\n",
       "      <th>PLAYER_IDX</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6873</th>\n",
       "      <td>203076</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Anthony Davis</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>3</td>\n",
       "      <td>1346</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6885</th>\n",
       "      <td>201933</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Blake Griffin</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>9</td>\n",
       "      <td>1074</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6891</th>\n",
       "      <td>203078</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Bradley Beal</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>27</td>\n",
       "      <td>1348</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6913</th>\n",
       "      <td>101108</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Chris Paul</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>8</td>\n",
       "      <td>1110</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6926</th>\n",
       "      <td>203081</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Damian Lillard</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>20</td>\n",
       "      <td>1351</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6947</th>\n",
       "      <td>201942</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>DeMar DeRozan</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>24</td>\n",
       "      <td>1082</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6948</th>\n",
       "      <td>202326</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>DeMarcus Cousins</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>3</td>\n",
       "      <td>1138</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7001</th>\n",
       "      <td>203507</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Giannis Antetokounmpo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>12</td>\n",
       "      <td>1467</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7040</th>\n",
       "      <td>201935</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>James Harden</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>8</td>\n",
       "      <td>1076</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7061</th>\n",
       "      <td>202710</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Jimmy Butler</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>13</td>\n",
       "      <td>1262</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7069</th>\n",
       "      <td>203954</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Joel Embiid</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>18</td>\n",
       "      <td>1541</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7074</th>\n",
       "      <td>202322</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>John Wall</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>27</td>\n",
       "      <td>1134</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7103</th>\n",
       "      <td>1626157</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Karl-Anthony Towns</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>13</td>\n",
       "      <td>875</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7112</th>\n",
       "      <td>201142</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kevin Durant</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>7</td>\n",
       "      <td>955</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7113</th>\n",
       "      <td>201567</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kevin Love</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>2</td>\n",
       "      <td>1016</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7121</th>\n",
       "      <td>204001</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kristaps Porzingis</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>15</td>\n",
       "      <td>1557</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7129</th>\n",
       "      <td>202681</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kyrie Irving</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>1</td>\n",
       "      <td>1234</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7130</th>\n",
       "      <td>200746</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>LaMarcus Aldridge</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>22</td>\n",
       "      <td>872</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7136</th>\n",
       "      <td>2544</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>LeBron James</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>2</td>\n",
       "      <td>660</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7198</th>\n",
       "      <td>203999</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Nikola Jokic</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>6</td>\n",
       "      <td>1556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7240</th>\n",
       "      <td>201566</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Russell Westbrook</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>23</td>\n",
       "      <td>1015</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7257</th>\n",
       "      <td>201939</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Stephen Curry</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>7</td>\n",
       "      <td>1080</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7303</th>\n",
       "      <td>203506</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Victor Oladipo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>17</td>\n",
       "      <td>1466</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      PLAYER_ID       TEAM_ID            PLAYER_NAME  ALL_STAR  YEAR  \\\n",
       "6873     203076  1.610613e+09          Anthony Davis       0.0  2017   \n",
       "6885     201933  1.610613e+09          Blake Griffin       0.0  2017   \n",
       "6891     203078  1.610613e+09           Bradley Beal       0.0  2017   \n",
       "6913     101108  1.610613e+09             Chris Paul       0.0  2017   \n",
       "6926     203081  1.610613e+09         Damian Lillard       0.0  2017   \n",
       "6947     201942  1.610613e+09          DeMar DeRozan       0.0  2017   \n",
       "6948     202326  1.610613e+09       DeMarcus Cousins       0.0  2017   \n",
       "7001     203507  1.610613e+09  Giannis Antetokounmpo       0.0  2017   \n",
       "7040     201935  1.610613e+09           James Harden       0.0  2017   \n",
       "7061     202710  1.610613e+09           Jimmy Butler       0.0  2017   \n",
       "7069     203954  1.610613e+09            Joel Embiid       0.0  2017   \n",
       "7074     202322  1.610613e+09              John Wall       0.0  2017   \n",
       "7103    1626157  1.610613e+09     Karl-Anthony Towns       0.0  2017   \n",
       "7112     201142  1.610613e+09           Kevin Durant       0.0  2017   \n",
       "7113     201567  1.610613e+09             Kevin Love       0.0  2017   \n",
       "7121     204001  1.610613e+09     Kristaps Porzingis       0.0  2017   \n",
       "7129     202681  1.610613e+09           Kyrie Irving       0.0  2017   \n",
       "7130     200746  1.610613e+09      LaMarcus Aldridge       0.0  2017   \n",
       "7136       2544  1.610613e+09           LeBron James       0.0  2017   \n",
       "7198     203999  1.610613e+09           Nikola Jokic       0.0  2017   \n",
       "7240     201566  1.610613e+09      Russell Westbrook       0.0  2017   \n",
       "7257     201939  1.610613e+09          Stephen Curry       0.0  2017   \n",
       "7303     203506  1.610613e+09         Victor Oladipo       0.0  2017   \n",
       "\n",
       "      TEAM_IDX  PLAYER_IDX  \n",
       "6873         3        1346  \n",
       "6885         9        1074  \n",
       "6891        27        1348  \n",
       "6913         8        1110  \n",
       "6926        20        1351  \n",
       "6947        24        1082  \n",
       "6948         3        1138  \n",
       "7001        12        1467  \n",
       "7040         8        1076  \n",
       "7061        13        1262  \n",
       "7069        18        1541  \n",
       "7074        27        1134  \n",
       "7103        13         875  \n",
       "7112         7         955  \n",
       "7113         2        1016  \n",
       "7121        15        1557  \n",
       "7129         1        1234  \n",
       "7130        22         872  \n",
       "7136         2         660  \n",
       "7198         6        1556  \n",
       "7240        23        1015  \n",
       "7257         7        1080  \n",
       "7303        17        1466  "
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_label_test.iloc[dnn_predict == 1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "归一化特征："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Train on 5480 samples, validate on 1370 samples\n",
      "Epoch 1/30\n",
      "5480/5480 [==============================] - 1s 221us/step - loss: 0.2973 - acc: 0.8739 - val_loss: 0.1278 - val_acc: 0.9496\n",
      "Epoch 2/30\n",
      "5480/5480 [==============================] - 0s 79us/step - loss: 0.1053 - acc: 0.9599 - val_loss: 0.0820 - val_acc: 0.9642\n",
      "Epoch 3/30\n",
      "5480/5480 [==============================] - 0s 79us/step - loss: 0.0945 - acc: 0.9611 - val_loss: 0.1153 - val_acc: 0.9547\n",
      "Epoch 4/30\n",
      "5480/5480 [==============================] - 0s 78us/step - loss: 0.0850 - acc: 0.9677 - val_loss: 0.0901 - val_acc: 0.9657\n",
      "Epoch 5/30\n",
      "5480/5480 [==============================] - 0s 89us/step - loss: 0.0774 - acc: 0.9682 - val_loss: 0.0872 - val_acc: 0.9672\n",
      "Epoch 6/30\n",
      "5480/5480 [==============================] - 0s 85us/step - loss: 0.0719 - acc: 0.9710 - val_loss: 0.0902 - val_acc: 0.9679\n",
      "Epoch 7/30\n",
      "5480/5480 [==============================] - 0s 75us/step - loss: 0.0673 - acc: 0.9724 - val_loss: 0.1151 - val_acc: 0.9591\n",
      "Epoch 8/30\n",
      "5480/5480 [==============================] - 0s 77us/step - loss: 0.0612 - acc: 0.9737 - val_loss: 0.1160 - val_acc: 0.9584\n",
      "Epoch 9/30\n",
      "5480/5480 [==============================] - 0s 78us/step - loss: 0.0605 - acc: 0.9754 - val_loss: 0.1428 - val_acc: 0.9518\n",
      "Epoch 10/30\n",
      "5480/5480 [==============================] - 0s 78us/step - loss: 0.0550 - acc: 0.9779 - val_loss: 0.1170 - val_acc: 0.9569\n",
      "Epoch 11/30\n",
      "5480/5480 [==============================] - 0s 85us/step - loss: 0.0536 - acc: 0.9785 - val_loss: 0.1242 - val_acc: 0.9577\n",
      "Epoch 12/30\n",
      "5480/5480 [==============================] - 1s 97us/step - loss: 0.0498 - acc: 0.9788 - val_loss: 0.1390 - val_acc: 0.9547\n",
      "Epoch 13/30\n",
      "5480/5480 [==============================] - 0s 84us/step - loss: 0.0494 - acc: 0.9797 - val_loss: 0.1303 - val_acc: 0.9562\n",
      "Epoch 14/30\n",
      "5480/5480 [==============================] - 0s 79us/step - loss: 0.0480 - acc: 0.9816 - val_loss: 0.1478 - val_acc: 0.9562\n",
      "Epoch 15/30\n",
      "5480/5480 [==============================] - 0s 76us/step - loss: 0.0468 - acc: 0.9816 - val_loss: 0.1462 - val_acc: 0.9547\n",
      "Epoch 16/30\n",
      "5480/5480 [==============================] - 0s 85us/step - loss: 0.0421 - acc: 0.9832 - val_loss: 0.1595 - val_acc: 0.9511\n",
      "Epoch 17/30\n",
      "5480/5480 [==============================] - 0s 83us/step - loss: 0.0415 - acc: 0.9841 - val_loss: 0.1698 - val_acc: 0.9496\n",
      "Epoch 18/30\n",
      "5480/5480 [==============================] - 0s 80us/step - loss: 0.0388 - acc: 0.9854 - val_loss: 0.1702 - val_acc: 0.9467\n",
      "Epoch 19/30\n",
      "5480/5480 [==============================] - 0s 80us/step - loss: 0.0383 - acc: 0.9849 - val_loss: 0.1745 - val_acc: 0.9474\n",
      "Epoch 20/30\n",
      "5480/5480 [==============================] - 0s 78us/step - loss: 0.0371 - acc: 0.9849 - val_loss: 0.1900 - val_acc: 0.9445\n",
      "Epoch 21/30\n",
      "5480/5480 [==============================] - 0s 81us/step - loss: 0.0347 - acc: 0.9861 - val_loss: 0.1930 - val_acc: 0.9423\n",
      "Epoch 22/30\n",
      "5480/5480 [==============================] - 0s 89us/step - loss: 0.0337 - acc: 0.9867 - val_loss: 0.2178 - val_acc: 0.9482\n",
      "Epoch 23/30\n",
      "5480/5480 [==============================] - 1s 94us/step - loss: 0.0370 - acc: 0.9870 - val_loss: 0.2035 - val_acc: 0.9453\n",
      "Epoch 24/30\n",
      "5480/5480 [==============================] - 0s 90us/step - loss: 0.0330 - acc: 0.9880 - val_loss: 0.2126 - val_acc: 0.9401\n",
      "Epoch 25/30\n",
      "5480/5480 [==============================] - 0s 88us/step - loss: 0.0309 - acc: 0.9874 - val_loss: 0.2129 - val_acc: 0.9423\n",
      "Epoch 26/30\n",
      "5480/5480 [==============================] - 0s 74us/step - loss: 0.0313 - acc: 0.9874 - val_loss: 0.2178 - val_acc: 0.9438\n",
      "Epoch 27/30\n",
      "5480/5480 [==============================] - 0s 76us/step - loss: 0.0311 - acc: 0.9889 - val_loss: 0.2436 - val_acc: 0.9350\n",
      "Epoch 28/30\n",
      "5480/5480 [==============================] - 0s 73us/step - loss: 0.0305 - acc: 0.9880 - val_loss: 0.2342 - val_acc: 0.9372\n",
      "Epoch 29/30\n",
      "5480/5480 [==============================] - 0s 81us/step - loss: 0.0309 - acc: 0.9885 - val_loss: 0.2488 - val_acc: 0.9343\n",
      "Epoch 30/30\n",
      "5480/5480 [==============================] - 0s 78us/step - loss: 0.0267 - acc: 0.9891 - val_loss: 0.2553 - val_acc: 0.9336\n"
     ]
    }
   ],
   "source": [
    "dim = df_data_train.shape[1]\n",
    "\n",
    "in_team = Input(shape=(1,))\n",
    "emb_team = Embedding(len(idx2team), 10)(in_team)\n",
    "emb_team = Flatten()(emb_team)\n",
    "\n",
    "in_player = Input(shape=(1,))\n",
    "emb_player = Embedding(len(idx2player), 10)(in_player)\n",
    "emb_player = Flatten()(emb_player)\n",
    "\n",
    "in_real = Input(shape=(dim,))\n",
    "\n",
    "in_all = concatenate([in_real, emb_team, emb_player])\n",
    "\n",
    "dense1 = Dense(200, activation=\"tanh\")(in_all)\n",
    "dense1 = Dropout(0.5)(dense1)\n",
    "out = Dense(2, activation=\"softmax\")(dense1)\n",
    "\n",
    "model3 = Model(inputs=[in_team, in_player, in_real], outputs=out)\n",
    "\n",
    "model3.compile(loss=\"sparse_categorical_crossentropy\", optimizer=\"rmsprop\", metrics=[\"accuracy\"])\n",
    "\n",
    "hist = model3.fit([df_label_train.TEAM_IDX, df_label_train.PLAYER_IDX, df_data_norm_train.iloc[idx]],  \n",
    "                  df_label_train.iloc[idx].ALL_STAR, \n",
    "                  validation_split=0.2,epochs=30, shuffle=True)\n",
    "dnn_predict = model3.predict([df_label_test.TEAM_IDX, df_label_test.PLAYER_IDX, df_data_norm_test]).argmax(axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>PLAYER_ID</th>\n",
       "      <th>TEAM_ID</th>\n",
       "      <th>PLAYER_NAME</th>\n",
       "      <th>ALL_STAR</th>\n",
       "      <th>YEAR</th>\n",
       "      <th>TEAM_IDX</th>\n",
       "      <th>PLAYER_IDX</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6851</th>\n",
       "      <td>203932</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Aaron Gordon</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>16</td>\n",
       "      <td>1525</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6871</th>\n",
       "      <td>203952</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Andrew Wiggins</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>13</td>\n",
       "      <td>1539</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6873</th>\n",
       "      <td>203076</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Anthony Davis</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>3</td>\n",
       "      <td>1346</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6883</th>\n",
       "      <td>1627732</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Ben Simmons</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>18</td>\n",
       "      <td>326</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6891</th>\n",
       "      <td>203078</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Bradley Beal</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>27</td>\n",
       "      <td>1348</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6902</th>\n",
       "      <td>203468</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>CJ McCollum</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>20</td>\n",
       "      <td>1434</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6914</th>\n",
       "      <td>203991</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Clint Capela</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>8</td>\n",
       "      <td>1551</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6921</th>\n",
       "      <td>1626156</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>D'Angelo Russell</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>14</td>\n",
       "      <td>81</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6926</th>\n",
       "      <td>203081</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Damian Lillard</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>20</td>\n",
       "      <td>1351</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6947</th>\n",
       "      <td>201942</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>DeMar DeRozan</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>24</td>\n",
       "      <td>1082</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6948</th>\n",
       "      <td>202326</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>DeMarcus Cousins</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>3</td>\n",
       "      <td>1138</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6984</th>\n",
       "      <td>202339</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Eric Bledsoe</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>12</td>\n",
       "      <td>1151</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6985</th>\n",
       "      <td>201569</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Eric Gordon</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>8</td>\n",
       "      <td>1018</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7001</th>\n",
       "      <td>203507</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Giannis Antetokounmpo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>12</td>\n",
       "      <td>1467</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7008</th>\n",
       "      <td>202355</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Hassan Whiteside</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>11</td>\n",
       "      <td>1166</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7036</th>\n",
       "      <td>1627750</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Jamal Murray</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>6</td>\n",
       "      <td>359</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7040</th>\n",
       "      <td>201935</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>James Harden</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>8</td>\n",
       "      <td>1076</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7051</th>\n",
       "      <td>1627759</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Jaylen Brown</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>1</td>\n",
       "      <td>369</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7052</th>\n",
       "      <td>1628369</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Jayson Tatum</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>1</td>\n",
       "      <td>1292</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7061</th>\n",
       "      <td>202710</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Jimmy Butler</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>13</td>\n",
       "      <td>1262</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7069</th>\n",
       "      <td>203954</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Joel Embiid</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>18</td>\n",
       "      <td>1541</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7103</th>\n",
       "      <td>1626157</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Karl-Anthony Towns</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>13</td>\n",
       "      <td>875</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7112</th>\n",
       "      <td>201142</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kevin Durant</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>7</td>\n",
       "      <td>955</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7121</th>\n",
       "      <td>204001</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kristaps Porzingis</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>15</td>\n",
       "      <td>1557</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7122</th>\n",
       "      <td>203937</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kyle Anderson</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>22</td>\n",
       "      <td>1529</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7129</th>\n",
       "      <td>202681</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Kyrie Irving</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>1</td>\n",
       "      <td>1234</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7130</th>\n",
       "      <td>200746</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>LaMarcus Aldridge</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>22</td>\n",
       "      <td>872</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7136</th>\n",
       "      <td>2544</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>LeBron James</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>2</td>\n",
       "      <td>660</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7188</th>\n",
       "      <td>1626167</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Myles Turner</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>17</td>\n",
       "      <td>105</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7198</th>\n",
       "      <td>203999</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Nikola Jokic</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>6</td>\n",
       "      <td>1556</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7199</th>\n",
       "      <td>202703</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Nikola Mirotic</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>4</td>\n",
       "      <td>1256</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7236</th>\n",
       "      <td>1626178</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Rondae Hollis-Jefferson</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>14</td>\n",
       "      <td>859</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7257</th>\n",
       "      <td>201939</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Stephen Curry</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>7</td>\n",
       "      <td>1080</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7303</th>\n",
       "      <td>203506</td>\n",
       "      <td>1.610613e+09</td>\n",
       "      <td>Victor Oladipo</td>\n",
       "      <td>0.0</td>\n",
       "      <td>2017</td>\n",
       "      <td>17</td>\n",
       "      <td>1466</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      PLAYER_ID       TEAM_ID              PLAYER_NAME  ALL_STAR  YEAR  \\\n",
       "6851     203932  1.610613e+09             Aaron Gordon       0.0  2017   \n",
       "6871     203952  1.610613e+09           Andrew Wiggins       0.0  2017   \n",
       "6873     203076  1.610613e+09            Anthony Davis       0.0  2017   \n",
       "6883    1627732  1.610613e+09              Ben Simmons       0.0  2017   \n",
       "6891     203078  1.610613e+09             Bradley Beal       0.0  2017   \n",
       "6902     203468  1.610613e+09              CJ McCollum       0.0  2017   \n",
       "6914     203991  1.610613e+09             Clint Capela       0.0  2017   \n",
       "6921    1626156  1.610613e+09         D'Angelo Russell       0.0  2017   \n",
       "6926     203081  1.610613e+09           Damian Lillard       0.0  2017   \n",
       "6947     201942  1.610613e+09            DeMar DeRozan       0.0  2017   \n",
       "6948     202326  1.610613e+09         DeMarcus Cousins       0.0  2017   \n",
       "6984     202339  1.610613e+09             Eric Bledsoe       0.0  2017   \n",
       "6985     201569  1.610613e+09              Eric Gordon       0.0  2017   \n",
       "7001     203507  1.610613e+09    Giannis Antetokounmpo       0.0  2017   \n",
       "7008     202355  1.610613e+09         Hassan Whiteside       0.0  2017   \n",
       "7036    1627750  1.610613e+09             Jamal Murray       0.0  2017   \n",
       "7040     201935  1.610613e+09             James Harden       0.0  2017   \n",
       "7051    1627759  1.610613e+09             Jaylen Brown       0.0  2017   \n",
       "7052    1628369  1.610613e+09             Jayson Tatum       0.0  2017   \n",
       "7061     202710  1.610613e+09             Jimmy Butler       0.0  2017   \n",
       "7069     203954  1.610613e+09              Joel Embiid       0.0  2017   \n",
       "7103    1626157  1.610613e+09       Karl-Anthony Towns       0.0  2017   \n",
       "7112     201142  1.610613e+09             Kevin Durant       0.0  2017   \n",
       "7121     204001  1.610613e+09       Kristaps Porzingis       0.0  2017   \n",
       "7122     203937  1.610613e+09            Kyle Anderson       0.0  2017   \n",
       "7129     202681  1.610613e+09             Kyrie Irving       0.0  2017   \n",
       "7130     200746  1.610613e+09        LaMarcus Aldridge       0.0  2017   \n",
       "7136       2544  1.610613e+09             LeBron James       0.0  2017   \n",
       "7188    1626167  1.610613e+09             Myles Turner       0.0  2017   \n",
       "7198     203999  1.610613e+09             Nikola Jokic       0.0  2017   \n",
       "7199     202703  1.610613e+09           Nikola Mirotic       0.0  2017   \n",
       "7236    1626178  1.610613e+09  Rondae Hollis-Jefferson       0.0  2017   \n",
       "7257     201939  1.610613e+09            Stephen Curry       0.0  2017   \n",
       "7303     203506  1.610613e+09           Victor Oladipo       0.0  2017   \n",
       "\n",
       "      TEAM_IDX  PLAYER_IDX  \n",
       "6851        16        1525  \n",
       "6871        13        1539  \n",
       "6873         3        1346  \n",
       "6883        18         326  \n",
       "6891        27        1348  \n",
       "6902        20        1434  \n",
       "6914         8        1551  \n",
       "6921        14          81  \n",
       "6926        20        1351  \n",
       "6947        24        1082  \n",
       "6948         3        1138  \n",
       "6984        12        1151  \n",
       "6985         8        1018  \n",
       "7001        12        1467  \n",
       "7008        11        1166  \n",
       "7036         6         359  \n",
       "7040         8        1076  \n",
       "7051         1         369  \n",
       "7052         1        1292  \n",
       "7061        13        1262  \n",
       "7069        18        1541  \n",
       "7103        13         875  \n",
       "7112         7         955  \n",
       "7121        15        1557  \n",
       "7122        22        1529  \n",
       "7129         1        1234  \n",
       "7130        22         872  \n",
       "7136         2         660  \n",
       "7188        17         105  \n",
       "7198         6        1556  \n",
       "7199         4        1256  \n",
       "7236        14         859  \n",
       "7257         7        1080  \n",
       "7303        17        1466  "
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_label_test.iloc[dnn_predict == 1]"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
